[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Compiler characteristics
From: |
Ralf Wildenhues |
Subject: |
Re: Compiler characteristics |
Date: |
Sun, 6 Sep 2009 12:19:49 +0200 |
User-agent: |
Mutt/1.5.20 (2009-08-09) |
* NightStrike wrote on Sun, Sep 06, 2009 at 12:08:23PM CEST:
> How do you test to see if the compiler supports a given option?
You could temporarily add it to CFLAGS and either do a compile or link
test, to find out. That won't catch (non-GCC) compilers though that
only produce a warning upon unknown flags.
IIRC there are macros in the Autoconf Macro Archive for similar
functionality.
Libtool has internal macros _LT_{COMPILER,LINKER}_OPTION that try to
detect compiler warnings for unknown flags, but such an approach is very
brittle in general.
> Specifically, gcc -municode
You could test $GCC ("yes" if gcc), and then a link test as described
above:
save_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -municode"
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
[echo works],
[echo fails])
CFLAGS=$save_CFLAGS
More fancily, cache the check, and announce what you're doing:
AC_CACHE_CHECK([whether $CC accepts -municode],
[ns_cv_cc__municode],
[save_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -municode"
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
[ns_cv_cc__municode=yes],
[ns_cv_cc__municode=no])
CFLAGS=$save_CFLAGS
])
if test $ns_cv_cc__municode = yes; then
some action based on the result ...
fi
Hope that helps.
Cheers,
Ralf