Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem with struct and pointer

Posted on 2004-04-13
5
Medium Priority
?
231 Views
Last Modified: 2010-04-01
Struct:

struct SapphireData
{
HBITMAP SapphireSwap;
};

Declarations:
SapphireData* SapphireData;
HANDLE hSapphireData = NULL;



Problem code:
if (hSapphireData != NULL)
      {
            SapphireData = (SapphireData*)hSapphireData;
      }


Why does the compiler throw up this error:

c:\Documents and Settings\Ryan Ross\Desktop\capture\hook\hookpaint.cpp(249): error C2059: syntax error : ')'

And how can I fix it?
0
Comment
Question by:rossryan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
bkfirebird earned 1000 total points
ID: 10820302
change SapphireData = (SapphireData*)hSapphireData;
to SapphireData = (struct SapphireData*)hSapphireData;

you will face this problem unless you typedef structs
0
 
LVL 10

Expert Comment

by:Sys_Prog
ID: 10820303
SapphireData* SapphireData;

The problem lies in above statement
U are declaring a pointer of type SapphireData with the same name as SapphireData

This is not allowed

Amit
0
 

Author Comment

by:rossryan
ID: 10820322
Now that's what I call a quick fix!
0
 
LVL 4

Expert Comment

by:bkfirebird
ID: 10820323
SapphireData* SapphireData;

you dont want to be doing something like this ... your variable name and struct name are the same
it will only cause confusion
0
 

Author Comment

by:rossryan
ID: 10820355
Yeah, I know...working with someone else's code, and it's a bit ambiguous.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question