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

Evgeny Grin <[email protected]>
Newsgroups gmane.comp.sysutils.autoconf.general
Message-ID <[email protected]>
Just just 

./configure CC=gcc CFLAGS=-std=c89

No patching needed. Simple.
-- 
Evgeny

On 5 October 2023 23:31:58 GMT+03:00, "Niels Möller" <[email protected]> wrote:
>Hi,
>
>I still intend GNU Nettle to work with a c89 compiler, and I've been
>testing for that by configuring with
>
>  ./configure CC='gcc -std=c89'
>
>This used to catch accidental use of more recent C language features,
>like declarations not at the start of a block.
>
>However, I just realized that with recent autoconf (I'm now using
>autoconf-2.71), AC_PROG_CC has become more helpful, and in this
>configuration it automatically changes CC to 'gcc -std=c89 -std=gnu11'.
>It's documented at
>https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.71/html_node/C-Compiler.html#index-AC_005fPROG_005fCC-1,
>
>  If necessary, options are added to CC to enable support for ISO
>  Standard C features with extensions, preferring the newest edition of
>  the C standard that is supported.
>
>I'm sure that is a very useful feature in most cases, and a natural
>extension of the ancient autoconf feature of automatically adding flags
>needed to enable c89 aka ANSI-C.
>
>However, it completely defeats this way of testing that the project can
>be built with a c89 ompiler.
>
>Is there some way of telling autoconf to be less helpful, and attempt to
>add options only when needed to enable some particular version (in my
>case c89, less conservative projects might want to target c99 in the
>same way), but not add anything to enable even later language features?
>
>An alternative but less general approach would be some hack to skip this
>magic in the specific case that the compiler is gcc and CC already
>includes some -std=* argument.
>
>I think similar concerns apply to AC_PROG_CXX, and maybe this kind of
>testing is more important there due to higher speed of C++ language
>changes.
>
>BTW, I suspect that there's a typo in the corresponding docs for
>AC_PROG_CXX, it says
>
>  After calling this macro, you can check whether the C++ compiler has
>  been set to accept standard C++ by inspecting the shell variable
>  ac_prog_cc_stdc.
>
>"ac_prog_cc_stdc" looks wrong, since that's for AC_PROG_CC, not AC_PROG_CXX?
>
>Regards,
>/Niels
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.