What is the purpose of using -pedantic in the GCC/G++ compiler?
c, c++, compiler-flags, g++, gcc
Solution
GCC compilers always try to compile your program if this is at all possible. However, in some cases, the C and C++ standards specify that certain extensions are forbidden. Conforming compilers such as GCC or g++ must issue a diagnostic when these extensions are encountered.
For example, the GCC compiler’s -pedantic option causes GCC to issue warnings in such cases. Using the stricter -pedantic-errors option converts such diagnostic warnings into errors that will cause compilation to fail at such points. Only those non-ISO constructs that are required to be flagged by a conforming compiler will generate warnings or errors.
Problem
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)? - What are the right circumstances for using these two options? - When should I use them? - Are they important?