How can I disable compiler extensions using C++ in Xcode? I have already try to find it in the Scheme section. But didn't find it there.
https://www.learncpp.com/cpp-tutorial/configuring-your-compiler-compiler-extensions/comment-page-1/#comment-446983
For those asking about Xcode, here is how you add compiler flags:
You're done! Click out to dismiss the popup and you'll see both flags have been added to the "Other C++ Flags" setting. You could also have single-clicked on the right and instead of the popup it turns into an editable text field. You can add flags this way too just by typing them all in one space-separated line. Just leave a space after $(OTHER_CFLAGS) and add your flags at the end. Don't remove $(OTHER_CFLAGS)!
Note 1: In Xcode 11.3 Build Settings, under the Warning Policies header you'll see settings for "Pedantic Warnings" and "Treat Warnings as Errors". Setting these both to "Yes" however, only seems to add the "-pedantic" flag. Not "-pedantic-errors" as we want. Not sure if bug or intended so for now I guess leave these both at "No" and use the Custom Compiler Flags setting as shown above.
Note 2: There is a Build Setting called "C++ Language Dialect". Just type in "dialect" in the search filter and you'll find it. You can click the drop-down and select C++17 here. This will send the flag "-std=c++1z" to the compiler so you don't have to manually add it to the custom flags setting.
Edit: Found out C++1z was the name of the draft version of C++17 before it was approved.
1.Select the project under which your target/executable belongs.
2.Select the target for which you want to provide the compiler flags.
3.Select "Build Phases" -> "compile sources"
4.Double click against the file which generates executable file.
5.Paste the compiler flag e.g. -fno-elide-constructors
That is it. Rebuild you target and you should not see any copy constructors getting ommitted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With