Does GCC have a pragma for turning C ++ 11 on and off?

I have several headers that struggle with C ++ 11, but I would like to use functions like initializer lists in my code. My research says that you can only enable new features on the command line, for example:

g++ -std=c++11 

I would really like to add the code:

 #pragma CXX11_OFF #include <old.hpp> #pragma CXX11_ON vector<int> v {1,2,3}; 

I could not find such a pragma. He exists?

+6
source share
4 answers

No. Such a pragma does not exist.

You can find a list of all the supported pragmas GPR addresses in Β§ 6.61 of the manual .

+7
source

I do not know if such a pragma exists. But turning C ++ 11 on and off during the same compilation module looks awkward to me. Perhaps you should put the "old" part inside the dll and import it into the "new" part. Then you can only compile the new part with C ++ 11 enabled

0
source

Since such a pragma does not exist, my suggestion is to rely on make / cmake to select the β€œcorrect” files based on the compilation flag.

0
source

#pragma GCC diagnostic warning "-std=c++11"

This line adds the cpp 11 flag to the compiler.

0
source

All Articles