Been meaning to post this for a while. I have to add a
#include <stdlib.h>
to chipmunk_types.h so that size_t is define'd.
stdlib.h needed for size_t
- Tam Toucan
- Posts: 141
- Joined: Tue Jun 23, 2009 4:26 pm
- Contact:
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: stdlib.h needed for size_t
That one has been silently bothering me for a while too. I think I came up with a decent workaround though.
The reason that was set to size_t in the first place was for 64bit compatibility. You get nasty warnings about casting pointers to integers of different sizes. Using size_t was the closest thing that I could find to a portable guarantee that it was an int size that was as big as the pointer size. Now, as these were all being used for hash values, so I didn't really care about the extra bits just that it was a mostly unique value. It seems that there are only 2 places where pointers were used directly as hash values in the Chipmunk code. Getting a hash value for a shape pair, and for post step callbacks.
I changed the hash value type back to unsigned int and added double casts when I need to convert a pointer to a hash value. That seems to work without complaint and does what I want it to do. I also added a 64bit build to my default OSX build so I should be able to catch 64bit issues more quickly.
The reason that was set to size_t in the first place was for 64bit compatibility. You get nasty warnings about casting pointers to integers of different sizes. Using size_t was the closest thing that I could find to a portable guarantee that it was an int size that was as big as the pointer size. Now, as these were all being used for hash values, so I didn't really care about the extra bits just that it was a mostly unique value. It seems that there are only 2 places where pointers were used directly as hash values in the Chipmunk code. Getting a hash value for a shape pair, and for post step callbacks.
I changed the hash value type back to unsigned int and added double casts when I need to convert a pointer to a hash value. That seems to work without complaint and does what I want it to do. I also added a 64bit build to my default OSX build so I should be able to catch 64bit issues more quickly.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Who is online
Users browsing this forum: No registered users and 6 guests