Re: Annoying compiler warnings (repost)
Re: Annoying compiler warnings (repost)
- Subject: Re: Annoying compiler warnings (repost)
- From: Finlay Dobbie <email@hidden>
- Date: Tue, 4 Sep 2001 18:59:04 +0100
If you have something like
ClassA.h:
#import ClassB.h
@interface ClassA {
ClassB *myClassB;
}
- something;
@end
ClassB.h:
#import "ClassA.h
@interface ClassB {
ClassA *myClassA;
}
- somethingElse;
@end
You are recursively importing headers, which the compiler doesn't like.
The workaround, as you have noticed, is to use @class. When you use
@class, you can safely import the ClassA.h and ClassB.h from the .m
files, which means that whenever you perform operations on myClassB and
myClassA, the compiler will know what they respond to.
Hope that helps,
-- Finlay
On Tuesday, September 4, 2001, at 06:38 pm, Rob Rix wrote:
Sorry for the repost, but it's been _quite_ a while, and I haven't seen
my message show up. Of course, my sending this will guarantee that it
will show up immediately, so if it does show up, please disregard this.
Sorry.
Hey, all.
I'm writing quite a lot of code these days, and I've learned a few
things.
For instance, the linker won't let me import the headers of classes
that I use, just the one I'm inheriting from. So, I have to use @class
to give the compiler a heads-up of the existence of classes that I'm
using.
Problem is, when making use of these classes, the compiler isn't seeing
the appropriate class definitions, just the heads-up (of course), so
it's telling me that these classes don't respond to things which I know
they respond to (because I wrote the damnable things), and it's
defaulting a lot of method's return types to id (when they are actually
things like int and double and classes and such).
It compiles fine, but it's still giving me far more warnings than I
like seeing. I like seeing _zero_ warnings. But if I try importing the
header of these classes, I get link errors, so it won't compile.
_Argh_.
Is there any way to defeat the link errors while still being able to
import the headers so the compiler won't keep telling me that classes
don'
t implement methods which they do, in fact, implement?
If it makes any difference, all this is part of a framework I'm making.
Thanks in advance,
-- Rob
For this is summer--we spin slowly on the edge of song. - Kira Byers
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev