Re: Traditional C rejects ISO C



On Sat, 12 Jun 2004 20:01:05 PDT, "Carl B. Constantine" said:

> Second, I'm obviouslly using gcc's -Wtraditional setting for these
> errors to come up, so my question was: how do I get rid of these errors
> so that everything works correctly while still using -Wtraditional?
> Should I even be using -Wtraditional?

'info gcc' (under 'Invoking gcc' and then 'warning options'):

`-Wtraditional (C only)'
     Warn about certain constructs that behave differently in
     traditional and ISO C.  Also warn about ISO C constructs that have
     no traditional C equivalent, and/or problematic constructs which
     should be avoided.

There then follows a long laundry list of close to 100 lines of things that
are totally legal in ISO C but not in "traditional" (for instance, a 'switch'
operand of 'long' type, or ANSI/ISO string concatenation, or initialization
of a union).  Interestingly enough, the only reason you're not *totally*
inundated with warnings is probably because it doesn't even bother
trying to flag ANSI function prototypes:

        * Use of ISO C style function definitions.  This warning
          intentionally is _not_ issued for prototype declarations or
          variadic functions because these ISO C features will appear
          in your code when using libiberty's traditional C
          compatibility macros, `PARAMS' and `VPARAMS'.  This warning
          is also bypassed for nested functions because that feature is
          already a gcc extension and thus not relevant to traditional
          C compatibility.

You should probably only worry about it if you're writing code that also has to
work under a K&R compiler - gcc no longer even supports '-traditional' except
for the preprocessor.  I personally  know for a fact that even the IBM RT
running AIX 2.2.1 from 1986: (yes, 20 megaherz clock, the *big* models had 16M
of memory if I remember right) would do at least gcc 2.7.1, which did at least
some of the ANSI features.

http://www.old-computers.com/museum/computer.asp?st=1&c=867

If you have a platform that *still* doesn't have an ANSI C, the right thing
to do is take it out back and shoot it.  Or donate it to a museum. ;)

Attachment: pgp5z6catjDbR.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]