The #pragma keyword is portable in the sense that it should always compile, despite the compiler. However, pragmas are specific to the compiler, so it is likely that when you change the compiler, it will complain about some warnings. Some pragmas are widely used, for example, from OpenMP. To make the code more portable, you can surround your #ifdef / #endif #ifdef , which depend on the compiler used. For instance:
#ifdef __ICC #pragma optimize #endif
Compilers usually define some macros, such as __ICC , which make the code know which compiler is being used.
source share