This note says:
-ansi
: tells the compiler to implement the ANSI language option. This turns off certain "features" of GCC which are incompatible with the ANSI standard.
-pedantic
: used in conjunction with-ansi
, this tells the compiler to be adhere strictly to the ANSI standard, rejecting any code which is not compliant.
First things first:
- What is the purpose of the
-pedantic
and-ansi
options of the GCC/G++ compiler (I couldn't understand the above description)? - Can anyone tell me the right circumstances for using these two options?
- When should I use them?
- Are they important?
If you're writing code that you envisage is going to be compiled on a wide variety of platforms, with a number of different compilers, then using these flags yourself will help to ensure you don't produce code that only compiles under GCC.
If your code needs to be portable then you can test that it compiles without any gcc extensions or other non-standard features. If your code compiles with
-pedantic -ansi
then in theory it should compile OK with any other ANSI standard compiler.