mardi 3 novembre 2015

How to detect if [[noreturn]] is supported by C++ compiler via cmake or preprocessor checks?

I'm working with some code that is supposed to support both C++11 and C++03. I would like to mark a function [[noreturn]] but since that does not exist in C++03 I'm trying to figure out how best to guard it with preprocessor symbols.

In this email thread, it's suggested to try to check whether an individual feature is supported rather than all of C++11:

http://ift.tt/1Mxw4QB

Todd Greer writes:

You might consider using code from Boost's config subsystem. There's a list of dozens of macros they define to set what features are available in what compilers here: http://ift.tt/1H5eC9V

--
Todd Greer
Principal Scientist, Affinegy, Inc.

However, I didn't find anything that seems to do what I want. (In the boost config stuff, or elsewhere.)

Does anyone know a way to do this directly with a C preprocessor trick, or know of an existing cmake module that detects this feature? (If not I guess I will try to kludge one together.)

Aucun commentaire:

Enregistrer un commentaire