Solved

Problem with struct and pointer

Posted on 2004-04-13
5
224 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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++.

762 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

21 Experts available now in Live!

Get 1:1 Help Now