You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
handling of defined() conditions nested in function like macros #75
defined() conditions in function like macros are not handled correctly.
minimal example, which expects __FOO__ to be defined or not.
#include <stdio.h>
#define macro(var) (defined(__ ## var ## __))
int main(void) {
#if macro(FOO)
printf("__FOO__ defined\r\n");
#else
printf("__FOO__ not defined\r\n");
#endif
return 0;
}
preprocessing with gcc gives:
# gcc -D__FOO__ -E test.c
[...]
int main (void) {
printf("__FOO__ defined\r\n");
return 0;
}
preprocessing with simplecpp gives
# simplecpp -D__FOO__ -E test.c
int main ( void ) {
printf( "__FOO__ not defined\r\n" ) ;
return 0 ;
}
The real world code i encountered the problem with is in parts.h of atmel software framework. They expect the user to define the chip, software is being compiled for, as __chipname__ and derive family, series and product line from this.
Activity
firewave commentedon Jul 3, 2025
It now reports: