Search code examples
c++gcccompilationicc

Two compilers do not like each other


I'm trying to compile code with ICC and facing an error:

/opt/intel/composer_xe_2013.2.146/compiler/include/xmmintrin.h(82): error:
linkage specification is incompatible with previous "_mm_malloc" (declared at
line 38 of "/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include/mm_malloc.h")
extern void* __ICL_INTRINCC _mm_malloc(size_t, size_t);

Looks like ICC and GCC conflict. But I can't exclude GCC from $PATH. How to fix this confusion?


Solution

  • The problem was in the code I compile. We include malloc header, which is different for ICC and GCC. And there was the GCC header name.

    The solution is:

    #if defined(__INTEL_COMPILER)
    #include <malloc.h>
    #else
    #include <mm_malloc.h>
    #endif // defined(__GNUC__)