Re: Problem with Objective-C++ Header Files
Stephen Furlani <[email protected]>
| Newsgroups | gmane.comp.macosx.devel |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Jan 8, 2010 at 2:41 PM, Christopher Stern <[email protected]>wrote: > > On Jan 8, 2010, at 1:18 PM, Stephen Furlani wrote: > > > > On Fri, Jan 8, 2010 at 1:18 PM, Christopher Stern <[email protected]>wrote: > > Thanks for the reply. > > The C++ library uses glxew, and the code claims to support AGL - > http://www.equalizergraphics.com/, so I'm not intentionally using > XWindows. I suspect that XWindows is not being properly excluded for > compiling on a Mac. I'll have to dig deep for that. > > I'm still a bit uncertain about using #define (and I'm wearing my C++ > ignorance here on my sleeve) to re-define something in a header file that > isn't redefined in the library. If I do this: > > *#define id eqID* > *#include "eq/eq.h"* > *#undef id* > > and eq.h has > > *class somethingA {* > *private:* > *void id ();* > *}* > > #define'd to: > > *class somethingA {* > *private:* > *void eqID ();* > *}* > > then it doesn't mess up eq.dylib which has > > *void somethingA::id() {}* > > and not > > *void somethingA::eqID() {}* > > > You are correct that this could confuse the linker. > > There's also no way I can get XCode to just ignore Obj-C keywords in > "eq/eq.h"? > > > No, the source file, with all '#include's '#include'ed is one stream of > text to the compiler. > The good news is that I don't think there are any true ObjC keywords that > don't start with '@'. > There are some things defined in standard headers like BOOL that may be > coming into conflict > but that's a problem that exists in pure 'C' space the Obj-ness or ++-ness > doesn't come into it. > > Note 'id' in ObjC is a typedef, not a keyword: > typedef struct objc_object { > Class isa; > } *id; > the example you give above, with a struct or class having a member called > 'id' shouldn't produce any conflict > shouldn't need any defines or anything, in fact, there are standard MacOSX > headers that have this. > > > I have the source for the library, so I could technically refactor (or hackfactor) it to make it work, I'd just really rather not. Thanks for the help. I'll hunt down the typedef issues and see if I can't be more intelligent with compiling under OBJC. For the sake of clarity, (and in case there's another larger unseen issue) I'll include two typical errors that show up when compiling as a .mm, that aren't there when compiled as a .cpp. The following code included in the headers: 185 /** Write a base::UUID. */ 186 template<> 187 inline DataOStream& DataOStream::operator << ( const base::UUID& id ) 188 { 189 base::UUID out( id ); 190 out.convertToNetwork(); 191 write( &out, sizeof( out )); 192 return *this; 193 } gives the following error: /Users/pebble/Documents/equalizer/build/XCode/include/eq/net/dataOStream.h:191: error: invalid conversion from 'eq::base::UUID (*)(objc_object*)' to 'const void*' including a couple other places where 'id' is used as a member or passed value. struct SessionGetIDMasterReplyPacket : public SessionPacket { SessionGetIDMasterReplyPacket( const SessionGetIDMasterPacket* request ) { command = CMD_SESSION_GET_ID_MASTER_REPLY; size = sizeof( SessionGetIDMasterReplyPacket ); requestID = request->requestID; *id* = request->*id*; // error shows up here, "unqualified-id before '=' token" } NodeID masterID; uint32_t requestID; uint32_t *id;* }; Again, thanks for the help. -- -Stephen Furlani Biomedical Software Engineer e: [email protected] c: 240-491-7288