Discussion:
AC_PROG_CC_C99 should prefer "c99" as name of compiler
Gavin Smith
2016-01-12 15:38:03 UTC
Permalink
I think it might be a good idea if AC_PROG_CC_C99 used "c99" in
preference to other command names ("cc") for the name of the C
compiler.

POSIX requires this command to be available:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html#tag_20_11

Why do I make this suggestion? It's due to a problem I had compiling a
program under OpenIndiana 11. The configure script found "cc" as the
compiler, and it passed the checks for C99 features. However, the
source code had

#define _XOPEN_SOURCE 600

before including system headers, and this led to an error message:

#error: "Compiler or options invalid; UNIX 03 and POSIX.1-2001
applications require the use of c99"

The system headers refuse to allow the program to compile, even though
it would in all likelihood be fine.

I wondered who was to blame for being nonconformant to standards:
OpenIndiana, or the autoconf script? OpenIndiana did have a C99
compiler and POSIX headers, but the right compiler just wasn't used. I
can't see any argument to say that OpenIndiana is the problem here. If
autoconf had tried for the C compiler under the standardized name
first, there wouldn't have been a problem.
Paul Eggert
2016-01-12 15:49:43 UTC
Permalink
I can't see any argument to say that OpenIndiana is the problem here.
I can. cc should just work. Any system where cc doesn't just work is
asking for trouble. In practice, the c99 command has more portability
problems on various platforms than the cc command does. Plus, POSIX is
going to change the name of the compiler to c11, so that's another
portability hassle looming. So cc it is.

Normally 'configure' tries gcc first. I assume you didn't have that
installed? You might try installing it.
Earnie
2016-01-12 15:50:12 UTC
Permalink
Post by Gavin Smith
I think it might be a good idea if AC_PROG_CC_C99 used "c99" in
preference to other command names ("cc") for the name of the C
compiler.
I don't disagree but I must ask if the CC environment variable was
perhaps enabled with cc as the compiler?
--
Earnie
Loading...