huahsin68 huahsin68 - 1 year ago 119
C Question

What is the purpose of using -pedantic in GCC/G++ compiler?

: tells the compiler to implement the ANSI language option. This turns
off certain "features" of GCC which
are incompatible with the ANSI

: used in conjunction with
, this tells the compiler to be adhere strictly to the ANSI standard,
rejecting any code which is not

Text above is extract from this note. First thing first, what is the purpose of usage of
option with GCC/G++ compiler, I couldn't understand the above description. Can anyone tell me the circumstances of using the above two options? When should I use it? Is it important one?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download