[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AC_PROG_CC: how to distinguish clnag from gcc?
From: |
Russ Allbery |
Subject: |
Re: AC_PROG_CC: how to distinguish clnag from gcc? |
Date: |
Fri, 05 Feb 2021 09:34:46 -0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
Sébastien Hinderer <Sebastien.Hinderer@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 (eagle@eyrie.org) <https://www.eyrie.org/~eagle/>
- Re: Weird behaviour about system types, (continued)
- Re: Weird behaviour about system types, Sébastien Hinderer, 2021/02/04
- Re: Weird behaviour about system types, Nick Bowler, 2021/02/04
- Re: Weird behaviour about system types, Sébastien Hinderer, 2021/02/05
- AC_PROG_CC: how to distinguish clnag from gcc?, Sébastien Hinderer, 2021/02/05
- Re: AC_PROG_CC: how to distinguish clnag from gcc?, Todd C. Miller, 2021/02/05
- Re: AC_PROG_CC: how to distinguish clnag from gcc?, Sébastien Hinderer, 2021/02/05
- Re: AC_PROG_CC: how to distinguish clnag from gcc?, David A . Wheeler, 2021/02/05
- Re: AC_PROG_CC: how to distinguish clang from gcc?, David A. Wheeler, 2021/02/05
- Re: AC_PROG_CC: how to distinguish clang from gcc?, Russ Allbery, 2021/02/05
- Re: AC_PROG_CC: how to distinguish clang from gcc?, Sébastien Hinderer, 2021/02/08
- Re: AC_PROG_CC: how to distinguish clnag from gcc?,
Russ Allbery <=
- Re: AC_PROG_CC: how to distinguish clnag from gcc?, Sébastien Hinderer, 2021/02/08
- Re: AC_PROG_CC: how to distinguish clnag from gcc?, Russ Allbery, 2021/02/08
- Re: AC_PROG_CC: how to distinguish clnag from gcc?, Sébastien Hinderer, 2021/02/09
- Re: AC_PROG_CC: how to distinguish clnag from gcc?, Paul Eggert, 2021/02/08