-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Support C23 typeof operator #191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The 'typeof' operator, originally a GNU extension, is now part of the C23 standard. This change enables its use in list macros where supported and explicitly cuts of non-typeof macros. Change-Id: I6a6e4e0caa4b72f16d957e0bd87722fac1915e3d
@jserv What do you think about the auto type placeholder since C23 (§6.7.9 Type inference)? Is it appropriate to use it here? Thanks! |
It sounds good. Just do it along with effective tests. |
The The error:
|
@lumynou5, which version of Cppcheck are you using? I am using Cppcheck 2.17 dev (build from source) and have not seen such errors. |
@jserv 2.16.0 from Arch Linux official repositories. I tested without the |
You can suggest some inlined Cppcheck suppression comments for me to apply. |
Because the macros are not defined, For example #if __LIST_HAVE_TYPEOF
#define list_for_each_entry_safe(entry, safe, head, member) \
for (entry = list_entry((head)->next, typeof(*entry), member), \
safe = list_entry(entry->member.next, typeof(*entry), member); \
&entry->member != (head); entry = safe, \
safe = list_entry(safe->member.next, typeof(*entry), member))
#else
#define list_for_each_entry_safe(entry, safe, head, member) \
for (entry = safe = (void *) 1; \
sizeof(struct { int : -1; }); \
++(entry), ++(safe))
#endif The purpose of the assignments and the increments are to avoid CppCheck complaining potential uninitialized variables, unused variables, and can-be-constant variables. |
Create a new issue along with the proposed changes. |
The 'typeof' operator, originally a GNU extension, is now part of the C23 standard. This change enables its use in list macros where supported.
Change-Id: I6a6e4e0caa4b72f16d957e0bd87722fac1915e3d