Re: Using C++ classes with Objective C code
Re: Using C++ classes with Objective C code
- Subject: Re: Using C++ classes with Objective C code
- From: p3consulting <email@hidden>
- Date: Fri, 10 Oct 2003 19:37:46 +0200
>
I want to use some C++ classes in a project that it otherwise all
>
Objective C. My attempt was to
>
>
1. Add the C++ classes to the project
>
2. Create an ObjC++ file (with extension .mm) to serve as interface
>
between main code and C++ classes. Whenever the main code needs results
>
from C++ classes, it will call functions in this interface file that
>
isolate pure Objective C code from C++ code.
>
>
At first it would not compile, but after cleaning the target, it
>
compiled, but now it will not link. When I try to call a function in
>
the interface (.mm) file, there is a linking error ("Undefined
>
symbols:") which corresponds to the called function in the interface
>
(.mm) file.
>
>
I have used these C++ classes in another project, but it that case most
>
Objective C files needed to use them so I just made every file have
>
extension .mm. How come the above process does not link?
>
>
It case it helps, here is some code
>
Classic C / C++ name space problem
in the header file declaring the interface functions of the .mm
you have to bracket the declarations by
#ifdef __cplusplus
extern "C" {
#endif
// your function declarations here
#ifdef __cplusplus
};
#endif
So that the C++ compiler knows that these function are in the C name
space
Pascal Pochet
P3 Consulting
email@hidden
http://www.p3-consulting.net
_______________________________________________
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.