I frequently hear that Objective-C is a "strict superset" of the C programming language. There are several dialects/standards of C (ie. K&R, ANSI C, C90, C99, GNU extensions...); Objective-C was first developed in the early 1980s, so it has to predate these standards. However, Objective-C 2.0 is from around 2006 or 2007, so it could be based on a more modern C dialect. So, which "C" is Objective-C a superset of?
4 Answers
There's a corresponding "dialect" of Objective-C for all the standard dialects of C.

- 234,037
- 30
- 302
- 389
-
2`@Chuck:` ...and some of the *non-standard* dialects of C! – iPhone Developer Nov 30 '10 at 19:40
Given that the most commonly used Objective-C compilers (GCC and Clang) are also C compilers, one would imagine that they support the C dialect(s) supported by these compilers. Apple's documentation specifically states:
The Apple compilers are based on the compilers of the GNU Compiler Collection. Objective-C syntax is a superset of GNU C/C++ syntax, and the Objective-C compiler works for C, C++ and Objective-C source code. The compiler recognizes Objective-C source files by the filename extension .m, just as it recognizes files containing only standard C syntax by filename extension .c. Similarly, the compiler recognizes C++ files that use Objective-C by the extension .mm. Other issues when using Objective-C with C++ are covered in “Using C++ With Objective-C”
So in this case Objective-C is simply regarded as an extension of either the C or C++ compiler depending on which you choose as the base language.

- 88,407
- 13
- 85
- 165
-
As of Xcode 4.4, the C dialect seems to be set to "GNU99" by default. – Zoodle Von Noodleson Aug 20 '12 at 21:21
What you're looking for isn't really defined. Objective C is usually thought of a strict superset of ANSI-C (which is the same as C90). However, Objective C isn't a standardized language or anything of that sort. It's description basically is "Take C, and add these features to it". It's therefore dependent on the particular compiler you're using.

- 104,103
- 58
- 317
- 552
-
Now I have to wonder how Xcode deals with C99 strict aliasing rules when compiling Objective-C code... – iPhone Developer Nov 30 '10 at 19:34
-
@iPhone Developer: I've never used Xcode, but iirc it's based on some form of GCC. If that is the case, then it should support any of the standards of C underlying objective C itself. – Billy ONeal Nov 30 '10 at 19:35
-
`@Billy ONeal:` Indeed: http://lists.apple.com/archives/objc-language/2005/Aug/msg00050.html – iPhone Developer Nov 30 '10 at 19:37
-
@iPhone Developer: All pointers to object types are equivalent to `id`, but get special type-checking from the Objective-C compiler. – Chuck Nov 30 '10 at 19:41
-
1"ANSI C" is not the same as C90. ANSI C is aligned with ISO C, whose present version is C99+TC1/2/3. – R.. GitHub STOP HELPING ICE Nov 30 '10 at 21:16
-
@R. Most people referring to ANSI C are distinguishing it from K&R C, and are referring to C89 or C90, not C99. – Billy ONeal Nov 30 '10 at 21:18
-
@iPhone Developer: The "strict aliasing" rules aren't new in C99 - the same rules existed in C90. The reason it has recently been raised as an issue is that GCC has started taking advantage of them for optimisation. – caf Nov 30 '10 at 21:46
-
@Billy ONeal: those people are using the name inaccurately; "ANSI C" has a clear, well-defined meaning. The fact that a lot of people are ignorant of that fact does not change the meaning of the term. – Stephen Canon Nov 30 '10 at 22:16
-
@Stephen: 1. I respectfully disagree. The word "hacker" isn't meant to have a negative connotation either, but it does in reality. Language is what people understand it as, not what happens to be written down on a piece of paper somewhere. 2. Most nobody uses the phrase "ANSI C" anymore in any case. The few places it's common to see it are distinguishing from K&R C, and those places were usually written before C99 was created, meaning that they actually refer to C89/C90, not C99. In either case, it's best to specify C89/90 or C99 explicitly or people **will** get confused like this. – Billy ONeal Nov 30 '10 at 22:35
-
@Billy ONeal: When discussing common language, I agree with the perspective you take -- words mean what people take them to mean. But we're not discussing common language; we're discussing language standards, and the terms have precise domain-specific meanings, divorced from "how the word is typically used". It's not possible to write or discuss a standard without this sort of strict interpretation. – Stephen Canon Nov 30 '10 at 22:49
According to "Learning Objective-C" from Apple:
"Objective-C is a superset of the ANSI version of the C programming language and supports the same basic syntax as C."

- 22,841
- 49
- 151
- 244