?
Solved

Problem with struct and pointer

Posted on 2004-04-13
5
Medium Priority
?
229 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

Independent Software Vendors: 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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

752 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