On 5/1/13 6:58 AM, James Peach wrote:
On May 1, 2013, at 12:48 AM, Igor Galić <i.ga...@brainsware.org> wrote:
Following this basic idea here
http://nadeausoftware.com/articles/2012/10/c_c_tip_how_detect_compiler_name_and_version_using_compiler_predefined_macros
I'd like to add a build/base_compiler.m4 - that runs this program:
# include <stdio.h>
int main (void) {
printf (
#if defined(__clang__)
"clang"
#elif defined (__GNUC__) || defined (__GNUG__)
"gcc"
#elif defined (__SUNPRO_C) || defined (__SUNPRO_CC)
"sunproc"
#elif defined (__ICC) || defined(__INTEL_COMPILER)
"icc"
#endif
);
return 0;
}
In addition to what James said, I think order could matter here. Like, I
suspect that ICC might define some of the gcc flags in its
"compatibility" mode. As such, I'd imagine you ought to test for most
specific first (e.g. icc then sunpro then clang and last gcc) ?
But +1 from me.
-- Leif