簡體   English   中英

如何使用ifdef檢測英特爾的編譯器(ICC)?

[英]How to detect Intel's compiler (ICC) with ifdef?

我想在 Linux 上使用英特爾當前的編譯器。 我有一個應該檢測編譯器的內聯宏。

它曾經適用於過去版本的 GCC 和 ICC。 但現在我得到了與 ICC extern inline ICC 現在是否定義了__GNUC__ 您將如何檢測 ICC 或英特爾的 C++ 編譯器 ICPC?

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

__INTEL_COMPILER就是你要找的。 (來源: ICC 手冊頁

以下網頁顯示了有關如何檢測最新英特爾編譯器的信息:

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-compiler-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 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM