Solved

Problem with struct and pointer

Posted on 2004-04-13
5
225 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
  • 2
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
bkfirebird earned 250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Converting to C# also VS2015 5 117
Focus not getting shifted out of  editbox 2 57
Would like to move button in a function 3 71
Unable to start eclipse ? 17 128
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

919 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now