Fabricio
Fabricio

Reputation: 7925

When compiling using -std=c99 do I need to use -pedantic or -ansi?

I'm C/GCC noob, sorry. Thank you.

Upvotes: 2

Views: 884

Answers (3)

raj_gt1
raj_gt1

Reputation: 4691

you can use -pedantic with either -std=c99 or -ansi.
-ansi and -std=c99 both are standard to be followed by compiler and conflict each other as only one standard can be follow at a time.

-padantic check the program with strict ISO C and ISO C++ standard and reject any forbidden expression . without this option some traditional C and C++ feature can be allowed.

Upvotes: 1

Clifford
Clifford

Reputation: 93476

The thing with -pedantic is that the clue is in the name; does anyone need to be pedantic?

If you need that level of compliance, then yes you need it, but resolving any of pedantic warnings is unlikely to affect the behaviour of your code, but rather just make more work.

Upvotes: 1

Chris Dodd
Chris Dodd

Reputation: 126243

Using -ansi is equivalent to using -std=c89 or -std=c++98 depending on whether you're compiling a C or C++ file, so you would not want to use it along with -std=c99 as it would conflict. -pedantic on the other hand is independent of -std so can be used along with it.

Upvotes: 9

Related Questions