Re: Mysterious Build Error
Re: Mysterious Build Error
- Subject: Re: Mysterious Build Error
- From: "Lloyd Dupont" <email@hidden>
- Date: Thu, 27 Mar 2003 09:54:58 +1100
one solution would be to do as NeXT did.
// -- MyAppHeader.h --
#import "First.h"
#import "Second.h"
// -- OneItemHeader.h --
#import <Foundation/Foundation.h>
#import "MyAppHeader.h"
.....
----- Original Message -----
From: "Chris Bracken" <email@hidden>
To: "Vincenzo Kreft-Kerekes" <email@hidden>
Cc: <email@hidden>
Sent: Thursday, March 27, 2003 9:35 AM
Subject: Re: Mysterious Build Error
>
The #import directive will include a file only once. If you include
Second.h in First.h and First.h in Second.h you're stuck. Try manually
building the translation unit in your head. For example, if you have
somefile.m that includes Second.h, the translation unit the compiler sees
is:
>
>
contents of First.h
>
contents of Second.h
>
contents of somefile.m
>
>
One possible solution is to *not* #import the First.h and Second.h in the
headers. Instead, include those files in First.m and Second.m, and use a
forward declaration in the headers such as:
>
>
@class First;
>
@interface Second : NSObject
>
...
>
@end
>
>
Chris
>
>
On Wednesday, March 26, 2003, at 02:00PM, Vincenzo Kreft-Kerekes
<email@hidden> wrote:
>
>
>Dear All,
>
>
>
>I'm trying to introduce two objects to each other using the most recent
PB
>
>but this apparently simple scheme fails during build with - parse error
>
>before "Second" - and I have no clue as to why this is nor why it
compiles
>
>if I remove the #import <First.h> line from Second.h, leaving everyhing
else
>
>untouched. In the sample files below both implementations are empty. What
am
>
>I missing here? I would greatly appreciate any hints.
>
>
>
>Thanks a lot,
>
>Vincenzo
>
>
>
>
>
>-- First.h --
>
>#import <Foundation/Foundation.h>
>
>#import <Second.h>
>
>
>
>@interface First : NSObject {
>
> Second *secondRef;
>
>}
>
>
>
>@end
>
>
>
>
>
>-- Second.h --
>
>#import <Foundation/Foundation.h>
>
>#import <First.h>
>
>
>
>@interface Second : NSObject {
>
>}
>
>
>
>@end
>
>_______________________________________________
>
>cocoa-dev mailing list | email@hidden
>
>Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
>Do not post admin requests to the list. They will be ignored.
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.