This is the mail archive of the gcc-help@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: How to use C89 with certain C99 features


On 05/04/2011 12:32, richardcavell@mail.com wrote:
Hi, everyone. I'm building a project in C. My idea is that I want it to
be mostly C89, except that I will be using certain features of C99. What
compiler flags do I need to tell GCC what I want?


What are you actually trying to achieve? The only reason I can think of for someone to write C89 standard is to be compatible with more limited or older compilers. If that's the case, then you should write C89 - not C99. Many compilers that are basically C89 (or C90, or ANSI) will accept a few C99 features, such as // comments. But they are very unlikely to accept more complex C99 features, such as newer ways to handle variadic parameters. Thus your code will only work with a proper C99 compiler, and thus might as well use --std=c99.




At present, if I compile with -std=c99, I get no errors or warnings at
all. If I compile with -std=c89, I get the following warnings:

(When I use macros with ... and __VA_ARGS__)
warning: anonymous variadic macros were introduced in C99

(When I use long string literals)
warning: string length '613' is greater than the length '509' ISO C90
compilers are required to support

(When I use vsnprintf)
warning: implicit declaration of function 'vsnprintf'

(When I initialize a struct with run-time data)
warning: initializer element is not computable at load time

Richard





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