I think my compiler understands C++11, but maybe not. Instead of trying it on existing messes of source code which are buggy anyway, is there some simple "hello world" level snippet of source code I can try to compile, which if it does compile without error, proves the compiler is reading it as C++11?
Asked
Active
Viewed 166 times
0
-
2Try passing `-v -std=c++11` flags to your compiler. – Basile Starynkevitch Jan 16 '15 at 18:44
-
Look at this question and answers: http://stackoverflow.com/a/10717525/2502409 – Nazar554 Jan 16 '15 at 18:45
-
1You can use the standard "hello world" program, just replace the string with a raw string literal - `R"(Hello World!)"` – Praetorian Jan 16 '15 at 19:42
-
@Praetorian R could be a macro. – Neil Kirk Jan 16 '15 at 19:58
3 Answers
4
Try this one,
auto f = [](){};
or write some code with rvalue reference.

imlyc
- 84
- 5
-
I'm not entirely sure this is correct, but from what I'm reading in 2019, it looks like that in the upcoming C++20, []<>(){} will be legal. – DarenW Jul 16 '19 at 05:02
3
Shortest thing possible:
[]{};
Is's a lambda-expression without argument list.

HolyBlackCat
- 78,603
- 9
- 131
- 207
3
The Problem is that compiler usually don't support a new standard completely from the start. Meaning, they may support one c++11 feature, but not another.
However, as far as c++11 is concerned, I think VC++ is the only major compiler that doesn't fully support it, even though you may have to enable the c++11 mode manually. For g++ you e.g. have to supply the compiler flag -std=c++11 (or -std=gnu++11) - the same holds true for newer versions like c++14).

MikeMB
- 20,029
- 9
- 57
- 102
-
Can someone mark it as duplicated of: http://stackoverflow.com/questions/5047971/how-do-i-check-for-c11-support – dau_sama Jan 17 '15 at 10:31