RE: [sort of OT] C++ headers and Objective-C++
RE: [sort of OT] C++ headers and Objective-C++
- Subject: RE: [sort of OT] C++ headers and Objective-C++
- From: "Guy Umbright" <email@hidden>
- Date: Fri, 10 May 2002 10:21:03 -0500
- Thread-topic: [sort of OT] C++ headers and Objective-C++
Indirectly you gave me answer with 'Are you *sure* that
"objfile.mm" really ends in ".mm", and not ".m"?'.
The objc file including the header was a .mm BUT a file including
the objc header was not and that is what was actually causing
the problem. So what I had was this
Controller.m
ObjcClass.h
CPPClass.h
Where it was controller.m that was complaining.
Thanks
>
-----Original Message-----
>
From: email@hidden [mailto:email@hidden]
>
Sent: Thursday, May 09, 2002 2:12 PM
>
To: email@hidden
>
Subject: Re: [sort of OT] C++ headers and Objective-C++
>
>
>
Guy Umbright wrote:
>
|OK, given this set of files:
>
|
>
|== objcfile.h
>
|
>
|//objective-c header
>
|#import <Cocoa/Cocoa.h>
>
|#include "aclass.h"
>
|
>
|@interface MyClass : NSObject
>
|{
>
| AClass* pClass;
>
|}
>
|:
>
|:
>
|@end
>
|
>
|
>
|== objcfile.mm
>
|
>
|//objective-c++ file
>
|#import objcfile.h
>
|:
>
|:
>
|
>
|== aclass.h
>
|
>
|//C++ header
>
|class TheClass;
>
|class AnotherClass;
>
|
>
|class AClass
>
|{
>
|:
>
|:
>
|
>
|when objcfile.mm is compiled each forward class declaration
>
|generates a "undefined type, found 'class'" error.
>
|
>
|Is this not valid? As it appears that it is not recognizing
>
|the aclass.h file as a C++ header, is there a way to convice the
>
|compiler that it is?
>
>
I took what you posted, did the necessary cleanup (delete
>
colons, add closing braces, add quotes to the "#import
>
objectfile.h" statement), and compiled the result. I got no
>
error messages at all. I'm using PB 2, but gcc 2.95. My code
>
(copied directly from what compiled successfully):
>
----------------------------------
>
// objcfile.mm
>
#import "objcfile.h"
>
----------------------------------
>
// objcfile.h
>
#import <Cocoa/Cocoa.h>
>
#include "aclass.h"
>
>
@interface MyClass : NSObject
>
{
>
AClass* pClass;
>
}
>
@end
>
----------------------------------
>
// aclass.h
>
class TheClass;
>
class AnotherClass;
>
>
class AClass
>
{
>
};
>
----------------------------------
>
>
Are you *sure* that "objfile.mm" really ends in ".mm", and
>
not ".m"? If I rename "objfile.mm" to "objfile.m", I get
>
exactly the errors you name, plus a host of others.
>
>
Alternatively, are you using PB to compile the file? If not,
>
then you may need to tell the compiler that "objfile.mm" is
>
an Objective-C++ file (rather than that "aclass.h" is a C++
>
header). I don't recall which flag does this, but it does
>
appear in the gcc documentations (which you can find under
>
"Developer Tools").
>
>
Glen Fisher
>
_______________________________________________
>
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.
>
This electronic mail message and any attached files contain information
intended for the exclusive use of the individual or entity to whom it is
addressed and may contain information that is proprietary, privileged,
confidential and/or exempt from disclosure under applicable law. If you are
not the intended recipient, you are hereby notified that any viewing, copying,
disclosure or distribution of this information may be subject to legal
restriction or sanction. Please notify the sender, by electronic mail or
telephone, of any unintended recipients and delete the original message
without making any copies.
_______________________________________________
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.