Re: [Plib-users] multiple definitions
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2002-11-09 14:35:09
|
Mat Davidson wrote: > Im running Mac OSX Jaguar, GCC 3.1 > > I can compile the libs from source and install them without a problem. > When I try to use the libs though I get a ton of errors associated with > the use of "inline" translation functions and overloads used in header > files such as ul.h and sg.h. For example, the following code throws errors: > > ul.h: line 275 > static inline void _ulEndianSwap(unsigned int *x) { > *x = (( *x >> 24 ) & 0x000000FF ) | > (( *x >> 8 ) & 0x0000FF00 ) | > (( *x << 8 ) & 0x00FF0000 ) | > (( *x << 24 ) & 0xFF000000 ) ; > } > > > static inline void _ulEndianSwap(unsigned short *x) { > *x = (( *x >> 8 ) & 0x00FF ) | > (( *x << 8 ) & 0xFF00 ) ; > } > > and also > > > sg.h: line 835 > extern void sgReflectInPlaneVec3 ( sgVec3 dst, const sgVec3 src, const > sgVec4 plane ) ; > inline void sgReflectInPlaneVec3 ( sgVec3 dst, const sgVec4 plane ) > { > sgReflectInPlaneVec3 ( dst, dst, plane ) ; > } > > > > Im compiling the projects with g++. Has anyone ever run into this? > Theres no way I can use plib like this, hopefully theres a way to fix > this. Please let me know if you have any ideas. This is weird, we've compiled PLIB with many C++ compilers and never seen this kind of thing before. I know GCC 3.1 is a lot tighter on the C++ standard than previous revisions - but I can't see what we are doing wrong here. I think this is your own fault somehow. It's almost as if you were using a C compiler instead of C++. Since this doesn't show up as a problem when you compile the LIBRARIES, but only when you compile the APPLICATION, that's not impossible. After all, PLIB includes those exact same functions - it would not have compiled if there was an error in those function definitions. 1) Are you sure you are compiling these headers into C++ programs? PLIB doesn't support C. 2) Are you sure you didn't accidentally wrap the header with: extern "C" { #include <plib/ul.h> } 3) Is it possible that you have an 'extern "C"{...}' wrapping some other header file...or inside some other header that might have a missing '}' ?? That's the only thing I can imagine this could be. My suspicions were raised by the nature of the error message you sent me earlier: /usr/include/plib/ul.h:273: declaration of C function `void _ulEndianSwap(short unsigned int*)' conflicts with Why "declaration of C function" ?? Why not just "declaration of function" ? That leads me to think that for some reason the compiler thinks these are C functions and not C++ - and of course function overloading is illegal in C. Since C++ functions with 'extern "C"' in front of them have to abide by C-style linkage conventions, they *CANNOT* be overloaded - even if they happen to be written in C++. That's my best shot - dunno if anyone else has any ideas. ---------------------------- Steve Baker ------------------------- HomeEmail: <sjb...@ai...> WorkEmail: <sj...@li...> HomePage : http://web2.airmail.net/sjbaker1 Projects : http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net |