ofxBox2d compiling issue

Hi,

Am quite new to of, am trying to compile the ofxBox2d addon in VSexpress2008 - pretty sure everything is included correctly but the compiler always returns:

“ofxbox2dpolygon.h(124) : error C2057: expected constant expression”

The line of code here is:
b2Vec2 vertexArray[count];

so I think the issue has something to do with it not knowing at this stage how large count is - has anyone else experienced this or has a fix?

Thanks,
Adam

oh yes, on VC++ you can’t allocate an array like that. curious that other compilers are fine with it.

either use a fixed amount:

#define MAX_B2D_VERTICES 1000
b2Vec2 vertexArray[MAX_B2D_VERTICES];

then use MAX_B2D_VERTICES in your code to check if you are going over, etc.

second, you can do:

b2Vec2 * vertexArray;

in .h, in .cpp :

vertexArray = new b2Vec2[count]

when count is known…

does that help?

take care!
zach

Great thanks!

Hey Zach, I found this old thread since I had the same problem now that I moved to VC2010.
I used the first part of the method you mention (changing the value of count to something like 1000) but I’m not sure what to do with the second part:

then use MAX_B2D_VERTICES in your code to check if you are going over, etc.

Wouldn’t giving a fixed value actually break something?
And what needs to be checked afterwards? :slight_smile:

If there is a newer thread about this problem, I’ll try and find it. =D