8

我想在 Linux 上使用英特尔当前的编译器。我有一个应该检测编译器的内联宏。

它曾经与过去版本的 GCC 和 ICC 一起工作。但现在我得到extern inline了ICC。ICC现在定义了__GNUC__吗?您将如何检测 ICC 或英特尔的 C++ 编译器 ICPC?

#ifndef INLINE
# if defined(__GNUC__) || defined(__GNUG__)
#  define INLINE extern inline
# else
#  define INLINE inline
# endif
#endif
4

2 回答 2

14

__INTEL_COMPILER就是你要找的。(来源:ICC 手册页

于 2012-11-23T18:19:24.690 回答
1

以下网页显示了有关如何检测最新英特尔编译器的信息:

https://software.intel.com/content/www/us/en/develop/articles/use-predefined-macros-for-specific-code-for-intel-dpcpp-compiler-intel-cpp-compiler-intel- cpp-编译器-classic.html

编辑(这是来自网站的代码,用于区分不同版本):

// Predefined macros Intel® DPC++ Compiler
// dpcpp only
#if defined(SYCL_LANGUAGE_VERSION) && defined (__INTEL_LLVM_COMPILER)
   // code specific for DPC++ compiler below
   // ... ...

  // example only
   std::cout << "SYCL_LANGUAGE_VERSION: " << SYCL_LANGUAGE_VERSION <<  std::endl;
   std::cout << "__INTEL_LLVM_COMPILER: " << __INTEL_LLVM_COMPILER << std::endl;
   std::cout << "__VERSION__: " << __VERSION__ << std::endl;
#endif


 //Predefined Macros for Intel® C++ Compiler
#if !defined(SYCL_LANGUAGE_VERSION) && defined (__INTEL_LLVM_COMPILER)
   // code specific for Intel C++ Compiler below
   // ... ...

   // example only
   std::cout << "__INTEL_LLVM_COMPILER: " << __INTEL_LLVM_COMPILER << std::endl;
   std::cout << "__VERSION__: " << __VERSION__ << std::endl;
#endif

// Predefined Macros for Intel® C++ Compiler Classic
// icc/icpc classic only
#if defined(__INTEL_COMPILER)
   // code specific for Intel C++ Compiler Classic below
   // ... ...

   // example only
   std::cout << "__INTEL_COMPILER_BUILD_DATE: " <<   _INTEL_COMPILER_BUILD_DATE << std::endl;
   std::cout << "__INTEL_COMPILER: " << __INTEL_COMPILER << std::endl;
  std::cout << "__VERSION__: " << __VERSION__ << std::endl;
#endif 
于 2021-03-25T13:55:44.010 回答