Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Disabling GNU C/C++ extensions in gcc

715 views
Skip to first unread message

Sandeep M.

unread,
Mar 4, 2000, 3:00:00 AM3/4/00
to

Is there a way to invoke gcc so that the GNU C/C++ extensions (which
include GNU's alternative keywords) are disallowed? I'm using gcc under
Linux. The -ansi flag still allows one to use these alternate keywords,
which aren't part of the ANSI spec. I'm wondering if there's a way to use
gcc so that it's a pure ANSI compiler, and header files are parsed only to
only read those commands that are purely ANSI compliant. Keywords such as
__attribute__, __inline__, __asm__, __typeof__, __mode__ etc. are causing a
headache for this custom parser I'm using, which only understands purely
ANSI compliant code.

Sandeep

Amit Ghosh

unread,
Mar 4, 2000, 3:00:00 AM3/4/00
to

[invalid and ultra long reply address deleted]

RTFM

-ansi -pedantic

--
Amit Ghosh
mailto:ma...@ghosh.de


Sandeep M.

unread,
Mar 4, 2000, 3:00:00 AM3/4/00
to

I did RTFM prior to posting my query. There's no need for snideness.

The -ansi -pedantic doesn't quite do it, because the compiler will still
accept the alternate keywords in the course of parsing a system header
file. What I'm looking for is a way to constrain the language so that
these keywords aren't accepted, and they don't come up in the course of
parsing the standard header files (e.g., iostream.h, stdio.h, math.h,
etc.). Can this be done somehow?

Sandeep

Robert Brady

unread,
Mar 6, 2000, 3:00:00 AM3/6/00
to
In comp.os.linux.development.apps Sandeep M. <smulgund-at-alumni-d...@no.spam> wrote:
>The -ansi -pedantic doesn't quite do it, because the compiler will still
>accept the alternate keywords in the course of parsing a system header
>file. What I'm looking for is a way to constrain the language so that
>these keywords aren't accepted, and they don't come up in the course of
>parsing the standard header files (e.g., iostream.h, stdio.h, math.h,
>etc.). Can this be done somehow?

Yes. I'm a little uncertain about why on earth you do want to do this, but
remember that you have the sourcecode to the compiler.

--
Robert

Aki M Laukkanen

unread,
Mar 7, 2000, 3:00:00 AM3/7/00
to
Sandeep M. wrote:
>The -ansi -pedantic doesn't quite do it, because the compiler will still
>accept the alternate keywords in the course of parsing a system header
>file. What I'm looking for is a way to constrain the language so that

Yes, because they're marked with __extension__. This is a mechanism
meant only for the system header files.

>these keywords aren't accepted, and they don't come up in the course of
>parsing the standard header files (e.g., iostream.h, stdio.h, math.h,
>etc.). Can this be done somehow?

Excuse me but I don't quite understand you. Do you want to get errors
when parsing system header files? Well, sed -e s/__extension__// is
your friend. Or do you want to remove all gcc extensions from the
system header files?

--
D.

0 new messages