Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Class Declaration, syntax error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Class Declaration, syntax error




On Oct 29, 2008, at 10:54 PM, Jesper Lagerberg wrote:

Now, when I compile this, I get the following three errors:

error: syntax error before 'LegDataObjectClass' (in the .h file)
error: 'aTempLegDataObject' undeclared (first use in this function) (in the .m file)
error: 'LegDataObjectClass' undeclared (first use in this function) (in the .m file)


There are no errors in the LegDataObjectClass itself.

I've checked thoroughly for spelling, capitalisation, and semicolons etc. I really don't get why I would get a syntax error! I've tried to change the declaration to another class (e.g. NSNumber *aTempLegDataObject;), and then there's no syntax error found. Could there be some obscure compound problem? Or maybe I'm just doing something silly...


You need to let the compiler know about the existence of LegDataObjectClass before you use it.

In the header file of the class where you declare the LegDataObjectClass instance variable you would typically forward declare the class:

@class LegDataObjectClass;	// <- This is probably what you're missing

@interface Foo : NSObject {
@private
	LegDataObjectClass *aTempLegDataObject;
}
- (void) doThe5;
@end


And in the implementation file you need to actually import LegDataObjectClass:


#import "LegDataObjectClass.h" // <- This is probably what you're missing

@implementation Foo

// Stuff

@end

Read more about this in the ObjC language PDF, and in any book on C.

j o a r


_______________________________________________ Do not post admin requests to the list. They will be ignored. Objc-language mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Class Declaration, syntax error (From: Jesper Lagerberg <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.