8

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")

Is there a defined 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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Seth Johnson
  • 14,762
  • 6
  • 59
  • 85
  • clang http://stackoverflow.com/questions/2658461/what-predefined-macro-can-i-use-to-detect-clang | VC http://stackoverflow.com/questions/15127522/how-to-ifdef-by-compilertype-gcc-or-vc – Ciro Santilli OurBigBook.com Jun 22 '16 at 12:27

3 Answers3

12

Take a look at the Pre-defined C/C++ Compiler Macros project on Sourceforge.

PGI's compiler has a __PGI macro.

Also, take a look at libnuwen's compiler.hh header for a decent way to 'normalize' compiler versioning macros.

Michael Burr
  • 333,147
  • 50
  • 533
  • 760
4

You could try this to see what macros are predefined by the compiler:

pgcc -dM

Maybe that will reveal a suitable macro you can use.

Ville Laurikari
  • 28,380
  • 7
  • 60
  • 55
  • 1
    Indeed. The output of that is shown at http://www.pgroup.com/support/tprs_70.htm, and there's __PGI (mentioned above), and __PGIC__, __PGIC_MINOR__, and __PGIC_PATCHLEVEL__, which give the major, minor, and patchlevel parts of the compiler version number. – Brooks Moses Aug 05 '09 at 19:33
  • And there's the joy of the parser taking double underscores and doing entertaining things with them. 'PGI' is prefixed with double underscores; the other three are both prefixed and suffixed with them. – Brooks Moses Aug 05 '09 at 19:34
0

Have you looked at the boost headers? Supposing they support PGI, they will have found a way to detect it. You could use that. I would start to search somewhere in boost/config.

sbi
  • 219,715
  • 46
  • 258
  • 445