I'm playing around with XCode and C++, and I noticed that I change the C++ standard (ie C++98, C++11, GNU17, etc.) by clicking my project in the left sidebar. See screenshot at bottom of this post.
However, when I change to C++98, the C++ statement auto x = 6;
still compiles and runs with no complaints. This is bad because auto requires C++11, so clearly my setting of the standard to C++98 is not in effect. Note that when I say "still compile and run", I mean that I'm clicking the "play" button in XCode.
I imagine several possibilities here:
Anyone know what I'm doing wrong here? I'm using XCode 13.4.1 (latest version as of July 2022) on macOS monterey on 2021 macbook pro 14 inch with M1 pro.
There's another possibility you overlooked:
auto x = 6;
This happens to be a perfectly valid declaration in prehistoric times. auto
meant something else entirely, and traces its lineage to C. Nobody was using it, so the keyword was re-purposed in C++11. But, this just happens to be valid code. You might want to try something like:
auto y = "hello world";
and then verify the behavior of your C++ compiler at various C++ levels.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.