Skip to main content
gamedev.net
🔒 Locked

C++ and C problem

Started by qesbit Mar 12, 2005 at 4:42 AM 1 replies 800+ views
Original Post
qesbit
qesbit
I am mixing C++ with an old program written in C. Everything is wrapped with extern "C" except I have one problem, I have a struct defined in C that is extern in another module. The C++ code compiles the struct different than the C. extern "C" { typedef struct foo ... extern foo myfoo; } I am porting this app to C++, hence I need to work with C for a while until I got it all up to C++. I heven't worked with C in so long I forgot the tricks involved.
doynax
doynax
I'm not sure exactly what you're refering to. C++ should compile most C-style structure definitions just fine.

Perhaps you're trying to accomplish something like this?
#ifdef __cplusplus# define C_LINKAGE "C"#else# define C_LINKAGE#endiftypedef struct foo_t foostruct foo_t { ...};extern C_LINKAGE foo myfoo;
qesbit
qesbit
I think it's a problem somewhere else. It's not important right now I have alot of other stuff to deal with right now :-)

But yeah, I had C linkage, but it was mangling the structure in C++ and unsure why right now.

Thanks

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.