Jump to content
  • Advertisement
Sign in to follow this  
styfir

Does MS C++ Express support the keyword ' struct'?

This topic is 3503 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

Hi, Does MS C++ Express support the keyword ' struct'? I ask because I used to code with VS 6 ," a long time ago - I know!" and now I've tried it in MS C++ Express Edition the same way as before and it keeps giving me errors when I try to compile! Does anyone know of this problem off hand before I post my code ?

Share this post


Link to post
Share on other sites
Advertisement
Well, there's no problem with struct. If you can from VC++6, try #defining

#define for if(1) for

then re-compile (in vc6). If you now get the same errors, the problem is for loop scoping...


for(int i=0;i<10;++i)
{
}

// this will cause an error on VC7+, but is valid in VC6.
std::cout << i <<std::endl;


Share this post


Link to post
Share on other sites

struct SHAPE
{
int x;
int y;
int rotation;
int x_size;
int y_size;
};

SHAPE shapeA;

void main()
{
shapeA.rotation=4;
}



main.cpp(9) : error C2065: 'shapeA' : undeclared identifier
main.cpp(9) : error C2228: left of '.rotation' must have class/struct/union
type is ''unknown-type''

I MUST be doing something wrong : this should be straight forward but it appears to be extremely frustrating!!!

Help!

Share this post


Link to post
Share on other sites
Does your project define, by any chance, the preprocessor definition "SHAPE" ? Other than that, I cannot imagine what could cause your code to fail.

Share this post


Link to post
Share on other sites
No, the code I posted above is the ONLY code I am using at the moment. If I change the 'shapeA' to any other variable name I still get the same errors!

Share this post


Link to post
Share on other sites
Heres a thought - when you try to access the member variable of a structure like
 shapeA.rotation 
aren't you supposed to get a drop down list of the available members when you type the dot "."?

I think I am but I aint gettin it.

Share this post


Link to post
Share on other sites
Works fine for me. Are you sure this is the only code you have? Have you tried starting a new, clean project from scratch and pasting the code into there?

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!