Reputation: 11232
If I specify the standard to ANSI C with -std=c89
, my code won't run until I perform certain changes to make it compliant with the standard. So do I even need -pedantic
at this point if I've already set the -std=c89
flag?
By the way, the idea was to write C code which is as platform independet as possible. I was already using -pedantic
as I knew it would make the compiler more strict. However, it also made sense to explicitly choose the ANSI C standard. For some reason I thought this would make -pedantic
superfluous because the switch to ANSI C produced many errors in itself and appeared "strict enough".
Upvotes: 3
Views: 824
Reputation: 11232
No, even though both -pedantic
and -std=c89
might individually cause your code to fail to compile, they don't do the same thing:
-std=c89
will tell the compiler which ISO standard to use (in this case ANSI C also known as C89 or C90)-pedantic
will tell the compiler how strict the chosen standard should be enforcedYou can also find the following helpful hint in the man page. -std=c89
is equivalent to -ansi
for which man gcc
says:
The
-ansi
option does not cause non-ISO programs to be rejected gratuitously. For that,-pedantic
is required in addition to-ansi
.
Upvotes: 1