[Top][All Lists]

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

Re: How to get autoconf to respect CC="gcc -std=c89"?

From: Nick Bowler
Subject: Re: How to get autoconf to respect CC="gcc -std=c89"?
Date: Mon, 9 Oct 2023 03:49:03 -0400

On 2023-10-08, Niels Möller <> wrote:
> I would have expected that every input that is valid c89 also is valid
> c99, so that support for c99 strictly implies support for c89. But there
> may be some corner case I'm not aware of.

It is not true in general that a valid C89 program is also valid
C99, but it is essentially always the case for "normal" programs and
especially for "portable" programs which simply have to deal with the
fact that you can't really rely on any compiler providing perfect
strict standards conformance modes.

The most obvious difference is probably that "restrict" can be used
as an identifier in C89 (and it is not reserved anywhere) but this is
disallowed in C99 as "restrict" is lexically a keyword.

Furthermore, it is also not true that a program valid for both standards
will necessarily do the same thing.  It is easy to construct examples of
such behaviour differences deliberately but it probably never happens

Here's one example of such a program (compare output when compiled
with gcc -std=c89 versus gcc -std=c99):

  #include <stdio.h>

  int main(void)
      "the compiler parses comments like C%d\n", 88 + 11 //**/ 11
    return 0;

Here's another:

  #include <stdio.h>

  enum { VER = 99 };
  int main(void)
     if ((enum { VER = 89 })0)
     printf("the compiler implements block scopes like C%d\n", VER);
     return 0;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]