Consider the following source file, which is (at least should be) valid C.
void id() {
}
I am trying to compile it with gcc -c test.m
, but I get the following error:
test.m:1: error: ‘id’ redeclared as different kind of symbol
<built-in>:0: error: previous declaration of ‘id’ was here
If Obj-C were a strict superset, wouldn't it mean that all valid C programs also valid Obj-C programs? Note that I am not #import
ing anything, nor am I linking.
Granted, maybe LLVM(1) is doing something magical by default, or maybe this is a bug in it.
(1): i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
EDIT: Let me clarify this question - the question is not about the id
part, I know it has special meaning. My point is that it is commonly said that Obj-C is a strict superset of C. However, this can't be the case if it has keywords that conflict with valid C programs.
So either id is not reserved by the compiler, or Obj-C is not a strict superset. The point of this question is to ask which is the case, or is there something obvious I am missing.