Using c89 in Xcode

2k views Asked by At

Is there any way to compile C code with c89 standard NOT c99 in Xcode (or another way with terminal)?

I've searched in Xcode settings but I didn't find any way to choose compiler or standard.

1

There are 1 answers

0
notadam On BEST ANSWER

You should add -pedantic-errors to Other C flags in your project settings, like so:

Solution

Of course, don't forget to set the C language dialect to C89 as well.

This will give you the appropriate compile time errors when you try to compile something that is not valid C89.

Optionally, if you want Xcode to compile your code regardless of incompatibilities, but only give you yellow warnings at the problematic lines, use -pedantic instead of -pedantic-errors.

In a nutshell, these flags make the compiler stick to the language standard more strictly, as opposed to the default behavior, which is to attempt compiling the code any way possible.

I hope this helps :)

Source (even though they mention this in the context of GCC, but the same flags apply for Clang as well)