Consider the following files, test.h and test.m:
test.h:
-------
/* Contributed by Nicola Pero - Tue Jan 16 04:09:06 GMT 2007 */
#include <objc/objc.h>
#include <objc/Object.h>
@interface TestClass : Object
+ (int) test;
@end
test.m:
-------
#include "test.h"
@implementation TestClass
+ (int) test
{
return 0;
}
@end
int main (void)
{
return [TestClass test];
}
My compiler is 4.1.1 20070105 (Red Hat 4.1.1-51).
If I compile the files in the standard way --
gcc test.m -lobjc
it all works.
If I first precompile test.h
gcc -x objective-c-header test.h
I get the test.h.gch file, which looks ok, but then compiling fails --
gcc test.m -lobjc
test.m:4: warning: cannot find interface declaration for
�TestClass�
test.m:4: error: redefinition of �struct TestClass�
(compilation aborts)
(I also got a compiler internal error once)
Using the -H option to gcc you can indeed confirm that compilation fails iff
the
precompiled ObjC header is used.
It seems that ObjC class declarations in ObjC headers are not read correctly/at
all from precompiled headers (C stuff works fine instead!). Very
disappointing. :-(
I hope I'm missing an option / something, else it's a bug that needs fixing :-(
Thanks
--
Summary: Precompiled headers don't seem to work with GNU ObjC
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: objc
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: n dot pero at mi dot flashnet dot it
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30479