Re: Protocol-related compilation warnings
Re: Protocol-related compilation warnings
- Subject: Re: Protocol-related compilation warnings
- From: Hamish Allan <email@hidden>
- Date: Wed, 8 Jun 2005 12:45:05 +0100
On 8 Jun 2005, at 04:50, Andrew White wrote:
I agree with Ondra.
I agree with both of you really. I rather failed to write what I
really mean, which is: shouldn't the reported error be "Cannot find
protocol declaration for "IOIViewDataSource"."?
As a general rule, any header file that requires something declared
in another header file should either import that header file or
(often better) have a forward declaration (eg "@protocol Foo;" or
"@class Bar;").
Since class Bar conforms to protocol Foo, the compiler needs all
the details of Foo at the point which it attempts to declare Bar.
Thus, you need to #import "p.h" into "q.h".
It's really irritating to tell the user that they must include/
import another header file before the header file in question for
things to work correctly. This is doubly true with "#import",
which allows the compiler to do all the duplicate header supression
for you. If I include your header, I expect any classes declared
in your header to work without needing other headers.
Yes, and I would usually write code this way -- I just thought it
made the demonstration of what I was trying to convey simpler.
Notwithstanding, Ondra's suggestion that I look at the minimal case
was very helpful because I found an unnecessary circular reference in
my interfaces, the elimination of which allowed me to organise my
import dependencies much more cleanly.
Thanks,
Hamish
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden