On the command line I can use clang -std=c++98 -pedantic-errors which will prevent me from using features of newer C++ versions.

How can I achieve the same thing with Xcode?

EDIT: Example code

#include <iostream>

int main(int argc, const char * argv[]) {
    int arr[] = {1,2,3,4,5};
    for(int& e : arr) {
        std::cout << e * e;
    return 0;

This is my desired behavior.

$ clang -std=gnu++98 main.cpp -pedantic-errors
main.cpp:5:16: error: range-based for loop is a C++11 extension [-Werror,-Wc++11-extensions]
    for(int& e : arr) {
1 error generated.

But running Xcode with the c++98 toolchain set doesn't error.

EDIT 2: I found a switch to make it warn, but it Xcode doesn't error. xcode disable c++11 extensions

EDIT 3: I found another switch to make warnings errors warnings to errors


Click on a Project file, then Build Settings and find C++ Language Dialect.

C++ Language Dialect in Xcode

Use this to get an error:

enter image description here

| improve this answer | |
  • Thanks for the reply! I updated my question. I've updated the C++ dialect to use c++98 but I'm still able to use, my example, range based for-loops. – cdignam Feb 5 '19 at 19:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .