Re: Bugs with Obj-C++ compiler
Re: Bugs with Obj-C++ compiler
- Subject: Re: Bugs with Obj-C++ compiler
- From: email@hidden
- Date: Tue, 13 Nov 2001 21:55:26 +0100
So the OBj-C++ compiler is confused by another method (from NSWindow)
which is completely non-related to my one.
Where is the bug ?
I'm seeing this in Objective-C only. And I don't find this to be a bug
but an expected warning.
Please take the time to read the entire message, or don't answer to it. IT
IS a bug since it is a perfectly correct code in Objective-C. Here is the
part you didn't read:
(...)the Obj-C compiler accepts it without even any warning (in that
case Point3D appears as a simple struct, though). Now if only I rename the
same file with ".mm" instead of ".m", I get a lot of errors (not only
here!)
So just changing the name of the file yields errors. Everything is correct
in Objective-C.
I give back the complete description of the problem here:
There is a lot of bugs in the Obj-C++ compiler (in particular it crashes
frequently; sometimes PB crashes with him, too). I don't bother to sent
each of them to Apple, but I would like to have advices on this one,
because it is particularly strange, as it expresses a subtle difference
with the Obj-C compiler:
I have a C++ struct named Point3D (which is basically three floats with a
few inline methods), an Objective-C protocol
@protocol Positionnable
-(Point3D)center;
.....
@end
and in another class, a call like:
id<Positionnable> item = newSelection;
[centerControl setCoordinatesValue:(Point3D)[item center]];
(Note the cast; I tried to help the compiler). TO ME it looks like valid
code, and the Obj-C compiler accepts it without even any warning (in that
case Point3D appears as a simple struct, though). Now if only I rename the
same file with ".mm" instead of ".m", I get a lot of errors (not only
here!
) starting with:
CCCObjectPositionController.mm:38: warning: multiple declarations for
method `center'
CCCObjectPositionController.mm: In function `':
/System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:241:
warning: using `-(void)center'
CCCObjectPositionController.mm: In function `':
Positionnable.h:35: warning: also found `-(struct Point3D)center'
CCCObjectPositionController.mm: In function `':
Positionnable.h:17: warning: also found `-(struct Point3D)center'
CCCObjectPositionController.mm:38: invalid use of void expression
So the OBj-C++ compiler is confused by another method (from NSWindow)
which is completely non-related to my one. Then it CHOOSES THE WRONG ONE,
and ends with an error (last line)! So I can't even ignore that...
After a lot of tries, I finally found a way to overcome that:
NSObject<Positionnable>* item = newSelection; // instead of id
does the trick.
Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.