This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: help regarding "-ansi" flag
- From: Ian Lance Taylor <iant at google dot com>
- To: Sayali Surve <sayalisurve at yahoo dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 16 Mar 2009 12:03:49 -0700
- Subject: Re: help regarding "-ansi" flag
- References: <613026.66587.qm@web94816.mail.in2.yahoo.com>
Sayali Surve <sayalisurve@yahoo.com> writes:
> For gcc 4.1.2, as per the man page of gcc, the default standard is gnu89 i.e. ISO C90 plus GNU extensions.
> "-ansi" also supports ISO C90 programs.
> Is the difference in using and not using "-ansi" flag is not enabling GNU extensions and enabling GNU extensions or is there any other difference as well??
I think the gcc 4.1 manual is pretty clear. Quoting
http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/C-Dialect-Options.html#C-Dialect-Options
This turns off certain features of GCC that are incompatible with
ISO C90 (when compiling C code), or of standard C++ (when compiling
C++ code), such as the asm and typeof keywords, and predefined
macros such as unix and vax that identify the type of system you are
using. It also enables the undesirable and rarely used ISO trigraph
feature. For the C compiler, it disables recognition of C++ style
`//' comments as well as the inline keyword.
The alternate keywords __asm__, __extension__, __inline__ and
__typeof__ continue to work despite -ansi. You would not want to use
them in an ISO C program, of course, but it is useful to put them in
header files that might be included in compilations done with
-ansi. Alternate predefined macros such as __unix__ and __vax__ are
also available, with or without -ansi.
The -ansi option does not cause non-ISO programs to be rejected
gratuitously. For that, -pedantic is required in addition to
-ansi. See Warning Options.
The macro __STRICT_ANSI__ is predefined when the -ansi option is
used. Some header files may notice this macro and refrain from
declaring certain functions or defining certain macros that the ISO
standard doesn't call for; this is to avoid interfering with any
programs that might use these names for other things.
Functions which would normally be built in but do not have semantics
defined by ISO C (such as alloca and ffs) are not built-in functions
with -ansi is used. See Other built-in functions provided by GCC,
for details of the functions affected.
If you have any questions about that, can you be more specific?
Ian