|
warning on if-zero-ed code on gcc 4.3.x, bug or feature?
|
05/14/2009 10:45 AM
post29444
|
warning on if-zero-ed code on gcc 4.3.x, bug or feature?
Look into the following code a.c, gcc or qcc a.c shows warning of the line begining with !!. Interesting is the warning
is on the missing of the end " in the 3rd arg in snprintf(). Why the compiler parses the line that is not in action?
Also, the parsing looks a bit selective: it won't say anything on the !!. If you add a line of garbage, say, aaaaaa, the
compiler also says nothing on it.
Thanks
Weijie
===================
#include <stdio.h>
void afunc(int status)
{
char buf[1024];
#if 0
!! snprintf(buf, sizeof(buf), "%04x, status);
#else
snprintf(buf, sizeof(buf), "%04x", status);
#endif
}
int main() {
return 0;
}
|
|
|