Extern - dereferencing pointer to incomplete type.

F

friend.05

I have three files.


graph.h:

My header file where I have typedef for my structure and function
delcaration

typedef struct _ipc_actors ipc_graph_actors;
typedef ipc_graph_type *ipc_graph_pointer;

ipc_graph_pointer ipc_graph_new(graph_pointer,char *, char *, char *,
char *, char *);



graph.c:


My funciton is implemented in this file. And also my sturcture defition
are in this file.


main.c:


Here I am calling my fuction ipc_graph_new(graph_pointer,char *, char
*, char *, char *, char *);


This return a one pointer which is pointer to struture which I have
define din graph.c


But when I try to use this pointer to access the attributes of this
structure it gives me following error:

dereferencing pointer to incomplete type.


I think I have to use extern somewhere, but I am not sure.
 
I

Ian Collins

friend.05 wrote:

You don't have to ask twice.
I have three files.


graph.h:

My header file where I have typedef for my structure and function
delcaration

typedef struct _ipc_actors ipc_graph_actors;
typedef ipc_graph_type *ipc_graph_pointer;

ipc_graph_pointer ipc_graph_new(graph_pointer,char *, char *, char *,
char *, char *);

graph.c:


My funciton is implemented in this file. And also my sturcture defition
are in this file.

main.c:

Here I am calling my fuction ipc_graph_new(graph_pointer,char *, char
*, char *, char *, char *);

This return a one pointer which is pointer to struture which I have
define din graph.c

But when I try to use this pointer to access the attributes of this
structure it gives me following error:

dereferencing pointer to incomplete type.

I think I have to use extern somewhere, but I am not sure.
No, the definition of the struct has to be visible to the compiler if
you wish to access its members.

Put the definition in the common header.
 
V

vamshi

Hai ian ,
What u said is correct that compiler has to see the definition of the
structure and it has to be placed in common headerfile, but in a good
design of the projects it is said to have the definitions of
datastructures in a c file and their declarations in relevent header
files. isnt there any way to make code error free this way?

Regards,
Vamshi.
 
I

Ian Collins

vamshi wrote:

Please don't top post.
Hai ian ,
What u said is correct that compiler has to see the definition of the
structure and it has to be placed in common headerfile, but in a good
design of the projects it is said to have the definitions of
datastructures in a c file and their declarations in relevent header
files. isnt there any way to make code error free this way?
Who's u?

If you want to use an opaque type to hide the structure definition, you
gave to provide accessor functions (which take a pointer to the
structure as a parameter) to access the structure members.
 
C

CBFalconer

vamshi said:
What u said is correct that compiler has to see the definition of
the structure and it has to be placed in common headerfile, but in
a good design of the projects it is said to have the definitions
of datastructures in a c file and their declarations in relevent
header files. isnt there any way to make code error free this way?

Rude top-posting ignored. Also offensive use of silly
abbreviations.
 
F

friend.05

Yes i need to keep structure definition opaque.

So wht midification I have to do so that I do not get an error.
 
G

Guest

friend.05 said:
Yes i need to keep structure definition opaque.

So wht midification I have to do so that I do not get an error.

Why do you think it is a good idea to reply to a message complaining
about top-posting and silly abbreviations by using more silly
abbreviations, messing up the quoting, leaving in the signature (again
complaining about top-posting!) and replying top-posted to a message
you're not even commenting on?
 
C

CBFalconer

friend.05 said:
Yes i need to keep structure definition opaque.

So wht midification I have to do so that I do not get an error.

Don't top-post. Your reply belongs after, or intermixed with, the
material to which you reply. See the links below.

--
Some informative links:
< <http://www.geocities.com/nnqweb/>
<http://www.catb.org/~esr/faqs/smart-questions.html>
<http://www.caliburn.nl/topposting.html>
<http://www.netmeister.org/news/learn2quote.html>
<http://cfaj.freeshell.org/google/>
 
S

santosh

friend.05 said:
Yes i need to keep structure definition opaque.

So wht midification I have to do so that I do not get an error.

Why're you consistently ignoring the posting and quoting advice being
given? If you persist you may find that you're ignored by a lot of
regulars, thus missing out on their possible contribution to your
questions.

Also please post under a single name. Morphing stinks of trolling.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top