"Axel Liljencrantz" <[EMAIL PROTECTED]> writes:

> On 3/28/06, James Antill <[EMAIL PROTECTED]> wrote:
>>
>> . try adding -std=gnu99 and/or -std=c99 to the CFLAGS in autoconf, if
>> it fails don't use it (and assume nothing is prototyped/available).
>>
>
> There are numerous actual tests of what functionality is available,
> the above method would ignore those and assume that any non-gcc
> compiler compes from the stoneage.

 No, I meant do something like...

XCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -std=c99"
AC_MSG_CHECKING(if -std=c99 works)
AC_CACHE_VAL(local_cv_has__std_c99,[
AC_TRY_RUN([
#include <stdlib.h>
#include <stdio.h>

int main() {
 return 0;
}],
local_cv_has__std_c99=yes,
local_cv_has__std_c99=no,
)])
AC_MSG_RESULT($local_cv_has__std_c99)
case x$local_cv_has__std_c99 in
xno) CFLAGS="$XCFLAGS" ;;
esac


...this will add -std=c99 to the CFLAGS, iif the compiler can generate
a working binary with that flag there.

> I've implemented something similar,
> though. This configure.ac snippet (must be used after AC_PROG_CC)
> tests if CC is gcc and if so, set a few switches that should improve
> the odds of things going right on gcc systems.
>
> #
> # If we are using gcc, set some flags that increase the odds of the
> # compiler producing a working binary...
> #
> if test "$CC" = gcc; then

 distcc/icc/tcc will all still fail.

>> . Add:
>>
>> #define _ISOC99_SOURCE 1
>>
>> ...somewhere in your headers (see /usr/include/features.h or
>> info libc).
>
> This is an interesting alternative. Fish doesn't actually use any C99
> language features that I know of, but it does use wprintf, which is
> defined in C99. Would it be more correct to define _ISOC99_SOURCE?

 Well that's the glibc specific fix, and it's a glibc problem :).
 In theory other OSes could remove wprintf from the namespace if the
compiler isn't in c99 mode, so it could be argued that the -std=c99 is
the better fix here (although I think glibc is the only one that tries
to play games like that).

> This method should hopefully have the advantage that a C99-conformant
> non-gcc compiler using glibc will work without intervention. Is there
> any reason not to do both?

 No, doing both will work fine.

-- 
James Antill -- [EMAIL PROTECTED]
http://www.and.org/and-httpd


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to