views:

410

answers:

3

I'm currently writing a very simple game engine for an assignment and to make the code a lot nicer I've decided to use a vector math library. One of my lecturers showed me the Sony Vector Math library which is used in the Bullet Physics engine and it's great as far as I can see. I've got it working on Linux nicely but I'm having problems porting it to work on OS X (intel, Snow Leopard). I have included the files correctly in my project but the C++ version of the library doesn't seem to compile. I can get the C version of the library working but it has a fairly nasty API compared to the C++ version and the whole reason of using this library was to neaten the code in the first place.

http://glosx.blogspot.com/2008/07/sony-vector-math-library.html

This blog post that I've stumbled upon seems to suggest something's up with the compiler? It's fairly short so I couldn't take a lot of information from it.

When I try to use the C++ version I get the following errors (expanded view of each error):

/usr/include/vectormath/cpp/../SSE/cpp/vectormath_aos.h:156:0
/usr/include/vectormath/cpp/../SSE/cpp/vectormath_aos.h:156: 
error: '__forceinline' does not name a type

second error:

/Developer/apps/gl test/main.cpp:7:0 In file included from /Developer/apps/gl test/main.cpp

/usr/include/vectormath/cpp/vectormath_aos.h:38:0 In file included from   
/usr/include/vectormath/cpp/vectormath_aos.h

/usr/include/vectormath/cpp/../SSE/cpp/vectormath_aos.h:330:0 In file included from
/usr/include/vectormath/cpp/../SSE/cpp/vectormath_aos.h

/usr/include/vectormath/cpp/../SSE/cpp/vecidx_aos.h:45:0 Expected constructor, destructor, 
or type conversion before '(' token in     /usr/include/vectormath/cpp/../SSE/cpp/vecidx_aos.h

Finally two errors at the end of the main.cpp file:

Expected '}' at the end of input
Expected '}' at the end of input

I've Googled my heart out but I can't seem to find any answers or anything to point me in the right direction so any help will be greatly received.

Thanks,

A: 

Which compiler are you using on OS X ? There are 4 to choose from in the standard Xcode 3.2 install and the default is gcc 4.2. You might be better off trying gcc 4.0.

Paul R
gcc4.2 is currently set as the default in Xcode. I tried out gcc4.0 and Xcode gave me 416 errors. The other compilers result in the same errors as gcc 4.2.
Jon Hocking
Paul R
Ah that's it! It turns out I didn't build the library properly, I re did the make install and used the scalar library and now it works perfectly. Thanks a lot for the help there guys and sorry for the rookie mistake!
Jon Hocking
+1  A: 

__forceinline is a reserved word that is supported by only a couple compilers. Clearly, your compiler does not support the __forceinline keyword and the code in question is non-portable.

A very poor workaround would be to pass a new define to your compiler that gives the keyword the correct meaning. E.g.: -D__forceinline=inline or -D__forceinline=__attribute__((always_inline)) (Thanks Paul!)

greyfade
For gcc a better define would be `-D__forceinline=__attribute__((always_inline))`
Paul R
Would this be done in the c++ code or would it have to be done elsewhere? Is there a different compiler I could install/use on OS X?
Jon Hocking
@Jon: This would be done in your project settings or makefile. The `-D` switch is a command-line parameter for the compiler.
greyfade
The -D switch is equivalent to putting `#define __forceinline inline` in your source file.
greyfade
A: 

The SSE version was assumed to be only for Microsoft Visual Studio. For other platforms (Mac etc) you can use the scalar version.

Bullet\Extras\vectormathlibrary\include\vectormath\scalar\cpp

Erwin Coumans