Sébastien Hinderer <sebastien.hinde...@inria.fr> writes:

> It seems AC_PROG_CC wrongly believes clang is gcc and that may cause
> problems when clang is passed a warning which is only supposrted by gcc,
> as is the case e.g. for -Wno-stringop-truncation.

> Is there a recommended way to determine for sure from a configure script
> whether the detected C compiler is clang or gcc?

You can test each individual flag, but I found that tedious and irritating
because I wanted to write a list of warning flags for Clang based on its
manual and a list of warning flags for GCC based on its manual.

Rather than try to detect GCC, I reversed the logic and tried to detect
Clang instead, which seems to be somewhat easier.

dnl Source used by RRA_PROG_CC_CLANG.
AC_DEFUN([_RRA_PROG_CC_CLANG_SOURCE], [[
#if ! __clang__
#error
#endif
]])

AC_DEFUN([RRA_PROG_CC_CLANG],
[AC_CACHE_CHECK([if the compiler is Clang], [rra_cv_prog_cc_clang],
    [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_RRA_PROG_CC_CLANG_SOURCE])],
        [rra_cv_prog_cc_clang=yes],
        [rra_cv_prog_cc_clang=no])])
 AS_IF([test x"$rra_cv_prog_cc_clang" = xyes], [CLANG=yes])])

-- 
Russ Allbery (ea...@eyrie.org)             <https://www.eyrie.org/~eagle/>

Reply via email to