This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -std=c89 shouldn't allow post-statement declarations


On Tue, 22 Jul 2003, Jamie Zawinski wrote:

> It might be sensible for this to be allowed with -std=gnu89, but
> -std=c89 should not allow syntax that was not a part of the C89 spec.

As you know from the manual, -std=c89 means "accept standard code" while
-pedantic means "reject nonstandard code".  -std=c89 should do very little
(since in general we should accept standard code anyway): it defines
__STRICT_ANSI__, reducing header namespaces and so requiring feature test
macros to use POSIX etc. functions; it disables predefined macros such as
"linux" that are in the user's namespace; it enables trigraphs; it
disables digraphs and a few other lexer features such as C++ comments and
hex floats that in rare cases affect the meaning of valid code; it
disables various built-in functions that are not in C89.  But we might
consider making -std=c89 imply -pedantic (with or without any -no-pedantic
option to turn it off) as this is a cause of persistent confusion.

This message could also be considered a hint that
<http://gcc.gnu.org/ml/gcc-patches/2003-07/msg01663.html> still needs
review: that patch is OK with the addition of a cross-reference to the
"Mixed Declarations" section of the manual that documents this as an
extension.  So 3.4 should have a specific warning option for this.

> I realize that using -pedantic helps with this, but I find that that
> causes too many warnings: e.g., I can't compile Gtk programs without a
> slew of warnings from their header files.

GCC carefully disables warnings in system headers - the problem here is
that the header includes (possibly from gtk-config) are done with -I
rather than -isystem so GCC doesn't know to disable warnings in those
headers.  Using -isystem should make the use of -pedantic in such cases
much more reasonable.  If there are still problems with the use of macros
defined in those headers, making those macros use __extension__ should
help.

-- 
Joseph S. Myers
jsm@polyomino.org.uk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]