470,849 Members | 1,100 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

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 1064
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by MarcJessome | last post: by
6 posts views Thread by Robert Lawson | last post: by
1 post views Thread by joserobenator | last post: by
7 posts views Thread by gretean | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.