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

Jacob Bachmeyer <[email protected]>
Newsgroups gmane.comp.sysutils.autoconf.general,gmane.comp.sysutils.autoconf.patches
Message-ID <[email protected]>
Niels Möller wrote:
> Paul Eggert <[email protected]> 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
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.