Community
cancel
Showing results for 
Search instead for 
Did you mean: 
jerryleo
Beginner
945 Views

Does Intel Compiler use both of __INTEL_COMPILER and __GNUC__ at the same time?

Jump to solution
Folloing codes will get warning #47: incompatible redefinition of macro and detected the compiler as GCC while compiling by icc.

#ifdef __INTEL_COMPILER
#define compiler "Intel"
#endif

#ifdef __GNUC__
#define compiler "GCC"
#endif

How can I detect Intel compiler by using the pre-defined compiler macros?

Thanks

Jerry
0 Kudos
1 Solution
TimP
Black Belt
945 Views

Perhaps OP wanted something like the often used:

#if defined __INTEL_COMPILER
#define COMPILER "Intel"
#elif defined __GNUC__
#define COMPILER "GCC"
#endif

or

#ifdef __INTEL_COMPILER
#define compiler "Intel"
#endif

#if defined __GNUC__
#if defined __INTEL_COMPILER
#error "not supporting Intel gcc-compatible (e.g. linux) compilers"
#endif
#define compiler "GCC"
#endif

View solution in original post

4 Replies
TimP
Black Belt
945 Views
How about putting the #ifdef __GNUC__ in a #else section, if that's what you want?
__GNUC__ has to be defined in order for header files which use it to work with icc.
945 Views
It is not 100% clear for me what TimP wrote:) so i'm re-wrtiting example
[cpp]#ifdef __INTEL_COMPILER
#define compiler "Intel"
#else
#define compiler "GCC"
#endif[/cpp]
--Vladimir
TimP
Black Belt
946 Views

Perhaps OP wanted something like the often used:

#if defined __INTEL_COMPILER
#define COMPILER "Intel"
#elif defined __GNUC__
#define COMPILER "GCC"
#endif

or

#ifdef __INTEL_COMPILER
#define compiler "Intel"
#endif

#if defined __GNUC__
#if defined __INTEL_COMPILER
#error "not supporting Intel gcc-compatible (e.g. linux) compilers"
#endif
#define compiler "GCC"
#endif

View solution in original post

jerryleo
Beginner
945 Views
Thanks for all kindly help

Jerry
Reply