Solved

Problem with struct and pointer

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

828 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