Advertisement Jump to content
Sign in to follow this  
SirOnion

How is an INT an invalid array subscript?

This topic is 4992 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

80 C:\Documents and Settings\Jimmy\Desktop\Jim'sFortress\OpenGL\Jim'sPrograms\gravity.cpp invalid types `GLfloat[int]' for array subscript This is the line it will highlight: xPull[index] = acc * cos(xyAngle); This is how it was declared: GLfloat xPull[MAX_PLANETS]; (MaxPlanets was defined with #define)

Share this post


Link to post
Share on other sites
Advertisement
index was a parameter in the function

function was created as:
void updatePull(GLfloat massPull,GLfloat xPull,GLfloat yPull,GLfloat zPull,GLfloat radiusPull,int index){...}

and called as:
for(int i = 0; i < MAX_PLANETS; i++)
tester.updatePull(planets.mass,planets.x,planets.y,planets.z,planets.radius,i);

Share this post


Link to post
Share on other sites
Quote:
Original post by SirOnion
index was a parameter in the function

function was created as:
void updatePull(GLfloat massPull,GLfloat xPull,GLfloat yPull,GLfloat zPull,GLfloat radiusPull,int index){...}

and called as:
for(int i = 0; i < MAX_PLANETS; i++)
tester.updatePull(planets.mass,planets.x,planets.y,planets.z,planets.radius,i);


Your paramter GLfloat xPull is wrong. It should be GLfFloat *xPull.
A to why I leave that as a exercise to a reader.

Share this post


Link to post
Share on other sites
Oh! Wow I'm dumb, I forgot I have a parameter with the same name as the array. I just got it, sorry I'm dumb :) Thanks for the help though

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!