autoconf-patches
[Top][All Lists]
Advanced

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

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


From: Jacob Bachmeyer
Subject: Re: How to get autoconf to respect CC="gcc -std=c89"?
Date: Sat, 07 Oct 2023 21:36:48 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.22) Gecko/20090807 MultiZilla/1.8.3.4e SeaMonkey/1.1.17 Mnenhy/0.7.6.0

Niels Möller wrote:
Paul Eggert <eggert@cs.ucla.edu> writes:

This doesn't let you say "I want either c89 or c99, but not c11".

That's right, I tried only the very simplest thing. Providing a list
makes sense, thoguh. What should the interface be?

  AC_C_STANDARD_VERSION([c99 c89])

looks reasonable to me; list in order of preference, and whitespace
separation. That's consistent with AC_PROG_CC. But that means that

  AC_C_STANDARD_VERSION([c89 c99])

is a bit meaningless; if compiler has c89, that's what will be used, and
if it doesn't have c89, it won't have c99 either.

Free compilers may behave that way, however I have vague memories of a compiler that dropped support for K&R function definitions many years ago, long before GCC did. Since Autoconf seeks portability, including to non-free systems, preferring C89 but accepting C99 is reasonable to express. There may be non-free compilers out there that do not accept C89 but do accept C99.

[...]
I considered trying this out, but then there's some impedance mismatch
between the whitespace separated list to AC_C_STANDARD_VERSION, and the
comma-separated list required by m4_map. Certainly doable, but what's
the easiest way to transform

  [c99 c89]

into [99, 89]

?

Some quick tests here suggest that "patsubst(patsubst([c99 c89], [c]), [ ], [, ])" should do that trick.

+  m4_ifdef([_AC_C_STANDARD_VERSION_LIST],
+    [m4_fatal([AC_PROG_C_STANDARD_VERSION should only be used once], 1)])
Why have this check?

I figured the user should get some error message if using
AC_C_STANDARD_VERSION too late, e.g., after some AC_FOO that implicitly
uses AC_PROG_CC, which will also trigger this check. Not sure of
m4_fatal is the right way to signals error to the user, though. (And
error message could be improved).

How about "error: AC_PROG_CC_STANDARD_EDITION used after AC_PROG_CC invoked"?


-- Jacob



reply via email to

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