[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AC_PROG_CC_C89 is not adding -std=c89 to CFLAGS
From: |
Zack Weinberg |
Subject: |
Re: AC_PROG_CC_C89 is not adding -std=c89 to CFLAGS |
Date: |
Mon, 16 Jan 2017 09:47:40 -0500 |
On Fri, Jan 13, 2017 at 8:12 PM, Dimitrios Apostolou <address@hidden> wrote:
>
> recent GCC versions default to C99 or even C11. I was expecting that adding
> AC_PROG_CC_C89 to configure.ac, would force C89, probably by using
> -std=gnu89. But this was not the case. Any ideas why?
Originally, AC_PROG_CC_C89 meant "make sure the C compiler supports
_at least_ C89". It was for programs that couldn't be compiled with a
K&R compiler. (Remember that Autoconf has been around since the
1990s.)
Nowadays, your use case is probably more common, but it's still rare
enough that I doubt it makes sense for Autoconf to have a built-in
feature for it. And I don't think we can safely change what
AC_PROG_CC_C89 does. I would suggest manually splicing `-std=gnu89`
into the CC variable (not CFLAGS) after AC_PROG_CC, conditional on
$GCC.
> /opt/csw/lib/gcc/i386-pc-solaris2.10/5.2.0/include-fixed/sys/feature_tests.h:346:2:
> error: #error "Compiler or options invalid for pre-UNIX 03 X/Open
> applications and pre-2001 POSIX applications"
Solaris is tedious like that, yes. But did you really _want_ an old
POSIX conformance level? I can see wanting POSIX.1-2001 specifically,
since -2008 removed a number of useful things (gettimeofday,
swapcontext, etc) but pre-2001 seems unlikely. You might try
AC_USE_SYSTEM_EXTENSIONS.
zw