Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Guest Anonymous Poster

RECT Beginner Problem

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

Hmmm... that looks fine, and I tried compiling it and had no errors. Is there something before the RECT that may be causing the compiler to not translate it correctly?

Share this post


Link to post
Share on other sites
Advertisement
My guess is that you arn't declaring the structure of RECT. It is part of the MFC headers in Visual C++, so if your project isn't including MFC, and you arn't explictly including any of the headers, then you will have to define it yourself. This isn't hard. The structure can be found in the help files:

typedef struct tagRECT {
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT;

Share this post


Link to post
Share on other sites
RECT is defined in windef.h which is automatically included if you include windows.h. So if it's a Windows app, regardless of the flavor, RECT is defined. Since he said he included all the appropriate headers, I'm guessing that windows.h was one of them.

If it's not a Windows program,, of course RECT would have to be defined.

Share this post


Link to post
Share on other sites
Ahhhh! Where is the code you gave us located? Is it outside of any function body? (I'm pretty sure it is). If so, that's your problem. You can declare a RECT (or any struct) globally, but you can't assign its members outside of a function body.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Here's what I've wrote :

RECT rect1 , rect2 , rect3 , rect4 , rect5 ;

line (21) rect1.left=4615;
rect1.top=3885;
rect1.right=28385;
rect1.bottom=12115;

And here what the Compiler says :
check.cpp(21) : error C2501: 'rect1' : Missing Declaration
check.cpp(21) : error C2371: 'rect1' : Newdefinition ; different Basis Types
check.cpp(21) : error C2239: Unexpected Token '.' after Declaration of 'rect1'
check.cpp(21) : error C2059: Syntax Error : '.'

I've included all important header files!

Share this post


Link to post
Share on other sites

  • 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!