用#ifdef检测编译器 [英] Detect compiler with #ifdef
问题描述
我正在尝试构建一个适用于多个平台和编译器的小代码。我使用断言,其中大部分可以关闭,但是当使用PGI的 pgicpp
使用 -mp
为OpenMP支持进行编译时,它会自动使用 - no_exceptions
选项:我的代码中的throw语句的任何地方都会生成致命的编译器错误。 (支持异常处理被禁用)
I'm trying to build a small code that works across multiple platforms and compilers. I use assertions, most of which can be turned off, but when compiling with PGI's pgicpp
using -mp
for OpenMP support, it automatically uses the --no_exceptions
option: everywhere in my code with a "throw" statement generates a fatal compiler error. ("support for exception handling is disabled")
是否有一个定义
d宏我可以测试来隐藏PGI上的 throw
语句?我通常使用gcc,它具有 GCC_VERSION
等。在PGI中找不到任何描述这些宏的文档。
Is there a define
d macro I can test to hide the throw
statements on PGI? I usually work with gcc, which has GCC_VERSION
and the like. I can't find any documentation describing these macros in PGI.
推荐答案
看看 Sourceforge上的预定义C / C ++编译器宏项目。
PGI的编译器有一个 __ PGI
宏。
PGI's compiler has a __PGI
macro.
另外,看一下 libnuwen的 compiler.hh标题,用于正常化编译器版本控制宏。
Also, take a look at libnuwen's compiler.hh header for a decent way to 'normalize' compiler versioning macros.
这篇关于用#ifdef检测编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!