473,466 Members | 1,381 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Could someone please explain me this error?

OK, I have this piece of code:

void method(void* parameter)
{
1: struct Data* dataOfReference=(struct Data*)parameter;
2: Info tmpInfo=(*dataOfReference).payload.data;
3: char* message;
....
}

Why does the compiler (gcc) complain about line 2?

'error: dereferencing pointer to incomplete type'

Shouldn't it be correct? I have a pointer, and I dereference it with
'*'...
Thanks
Jun 27 '08 #1
5 1183
On May 2, 12:53*pm, Alexander Mahone <salvodanilogiuffr...@gmail.com>
wrote:
void method(void* parameter)
{
1: * *struct Data* dataOfReference=(struct Data*)parameter;
2: * *Info tmpInfo=(*dataOfReference).payload.data;
3: * *char* message;
}

Why does the compiler (gcc) complain about line 2?

'error: dereferencing pointer to incomplete type'

Shouldn't it be correct? I have a pointer, and I dereference it with
'*'...
what is the definition of struct Data?

--
Nick Keighley

Jun 27 '08 #2
Alexander Mahone wrote:
OK, I have this piece of code:

void method(void* parameter)
{
1: struct Data* dataOfReference=(struct Data*)parameter;
2: Info tmpInfo=(*dataOfReference).payload.data;
3: char* message;
....
}

Why does the compiler (gcc) complain about line 2?

'error: dereferencing pointer to incomplete type'
Is the complete definition of struct Data (not just a forward
declaration) visible to the compiler? It looks like you have left out a
header file.

--
Ian Collins.
Jun 27 '08 #3
In article <f9**********************************@x41g2000hsb. googlegroups.com>,
Alexander Mahone <sa******************@gmail.comwrote:
>void method(void* parameter)
{
1: struct Data* dataOfReference=(struct Data*)parameter;
2: Info tmpInfo=(*dataOfReference).payload.data;
Where's the definition of struct Data?
>Why does the compiler (gcc) complain about line 2?

'error: dereferencing pointer to incomplete type'

Shouldn't it be correct? I have a pointer, and I dereference it with
'*'...
You have a pointer to a struct Data, and to dereference it you
need a definition of that struct. Presumably you don't have one.

-- Richard
--
:wq
Jun 27 '08 #4
Alexander Mahone wrote:
1: struct Data* dataOfReference=(struct Data*)parameter;
If you need the cast, then there's a chance this is wrong.
2: Info tmpInfo=(*dataOfReference).payload.data;
Easier on the eye is...

Info tmpInfo = dataOfReference->payload.data;

--
Peter
Jun 27 '08 #5
void method(void* parameter)
{
1: struct Data* dataOfReference=(struct Data*)parameter;
This cast is bogus, and hides real bugs.
2: Info tmpInfo=(*dataOfReference).payload.data;
3: char* message;
...
}

Why does the compiler (gcc) complain about line 2?
because it doesn't now what struct Data looks like, hence the 'incomplete'.

Igmar.
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Eugene Safrankow | last post by:
Hello All! I've encountered with the error when I call a method of dependency library (written in managed VC++) from Smart Client placed on a web page. In general, I make a call to the Windows...
3
by: MarcJessome | last post by:
Hi, I was wondering if someone could help me through learning C++. I've tried learning before, but I find I would work better if I had someone that could help explain a few things to me. Im using...
6
by: Robert Lawson | last post by:
I continue to get the below error message when trying to load a aspx file. Could someone please point me in the right direction for solving this? I'm trying to access an access data base and I'm...
1
by: joserobenator | last post by:
All right. I'v been the last 24h looking everywhere for a solution: -- Description: An error occurred during the processing of a configuration file required to service this request. Please...
6
by: sparks | last post by:
extracalc = Switch(Me.Parent.Race_Black = -1 And Me.Parent.Sex = "Female", 1.952, Me.Parent.Race_Black = -1, 1.21, Me.Parent.Sex = "Female", 0.742, 1) I look at this and say ok if race = black...
7
by: gretean | last post by:
I have a problem that's driving me crazy involving Microsoft's ability to deduce template parameters. I am using Visual Studio .NET (aka VC7?), and it gives an error compiling the following code....
8
by: Bart | last post by:
Could someone explain me what is wrong with this code ? I gives me a compile error: Error 1 Use of unassigned local variable 'fileStreamObject' C:\Documents and Settings\Bart\Local...
2
by: patrice.pare | last post by:
Hello, Here is a summary of my Dev Environment: I use Visual Studio 2005 Team Suite SP1 with Crystal Report XI SP1 on a Windows XP SP2 development workstation. I also use SQL Server 2000 SP4. ...
1
by: okonita | last post by:
I need major help resolving a UDF error. My environment id DB2 UDBv8.2 and v9.1 on a Linux and Windows server. I am getting a SQL20148N error which states as follows: SQL20148N Routine...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.