[Top][All Lists]

[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 <> 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.
#if ! __clang__

[AC_CACHE_CHECK([if the compiler is Clang], [rra_cv_prog_cc_clang],
 AS_IF([test x"$rra_cv_prog_cc_clang" = xyes], [CLANG=yes])])

Russ Allbery (             <>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]