- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
#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
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
__GNUC__ has to be defined in order for header files which use it to work with icc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for all kindly help
Jerry
Jerry

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page