Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which dialect of C is Objective-C a "strict superset" of?

Tags:

c

objective-c

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?

like image 804
iPhone Developer Avatar asked Nov 30 '10 19:11

iPhone Developer


3 Answers

There's a corresponding "dialect" of Objective-C for all the standard dialects of C.

like image 138
Chuck Avatar answered Sep 21 '22 14:09

Chuck


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.

like image 23
Clifford Avatar answered Sep 19 '22 14:09

Clifford


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.

like image 37
Billy ONeal Avatar answered Sep 22 '22 14:09

Billy ONeal