On 3/28/06, James Antill <[EMAIL PROTECTED]> wrote:
> "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.

Ok. I was under the impression that -std=... was a GCC-specific flag,
not a generic CC flag like -O2. But if it is standard (real or
defacto), then your suggestion makes sense. I'll add it.

>
> > 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.

You would think so. Actually, I've spent the evening installing ICC to
see how fish works, and under ICC, *wprintf is prototyped by default.
I guess ICC sets a CPP preprocessor symbol or something. Anyway, fish
seems to compile just fine with ICC, though ICC emitted a bunch of
rather meaningful warnings (and a few caused by glibc header
strangeness).

But your point is still valid.

>
> >> . 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.

Then I guess I'll do that. Doesn't seem to be a preincluded autoconf
test to see if libc is glibc. Shouldn't be hard to write one, though.

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

--
Axel


-------------------------------------------------------
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&kid0944&bid$1720&dat1642
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to