The gcc warning options document says the -pedantic
option is supposed to give warnings for forbidden extensions out of strict ISO C.
However, when I compile the following code with my gcc version 9.4.0 with -pedantic
only, it warns nothing.
#include <stdio.h>
int main(void) {
int foo;
typeof(foo) bar = 42;
printf("%dn", bar);
}
I thought gcc would catch typeof()
as an error since it is a gcc extension and not a part of the C17 standard. Only when both -pedantic
and -std=c17
were set, instead of the default -std=gnu17
, I could find desired warnings (“implicit declaration of function ‘typeof’”).
How does exactly -pedantic
work? Is it being “weakly pedantic” without specifying an ISO C version?