Pages: [1]
Author Topic: ofxBox2d compiling issue  (Read 825 times)
badadam

Posts: 4

Gravatar


ofxBox2d compiling issue
« on: November 01, 2009, 04:42:53 PM »

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
Logged
zach
Administrator
brooklyn

Posts: 1906

Gravatar


WWW
Re: ofxBox2d compiling issue
« Reply #1 on: November 01, 2009, 05:55:13 PM »

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
Logged
badadam

Posts: 4

Gravatar


Re: ofxBox2d compiling issue
« Reply #2 on: November 02, 2009, 06:03:14 PM »

Great thanks!
Logged
irregular
Santiago, Chile

Posts: 359

Gravatar


Re: ofxBox2d compiling issue
« Reply #3 on: September 02, 2011, 11:14:06 PM »

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:

Quote
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? :)

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

Pages: [1]
 
Jump to:  

Powered by SMF 1.1.15 | SMF © 2011, Simple Machines

viagra priser