Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

XCode project's choice of C++ standard is not being respected

I’m playing around with XCode and C++, and I noticed that I change the C++ standard (i.e. 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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  • there’s some super hidden "save" button that I missed that I’m required to click to actually get the setting to stick
  • the action of "clicking the play button in XCode" does not actually use the new setting but rather uses old settings (and there needs be some kind of "make clean"-like ritual I need to do first in order to get the "play" button to respect new project settings
  • this setting is not working at all and it’s a bug in XCode

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.

enter image description here

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading