473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Extern - dereferencing pointer to incomplete type.

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.

Nov 22 '06 #1
8 3821
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.

--
Ian Collins.
Nov 22 '06 #2

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.
On Nov 22, 12:04 pm, Ian Collins <ian-n...@hotmail.comwrote:
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.

--
Ian Collins.
Nov 22 '06 #3
vamshi wrote:

Please don't top post.
>
On Nov 22, 12:04 pm, Ian Collins <ian-n...@hotmail.comwrote:
>>friend.05 wrote:You don't have to ask twice.
>>>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.
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.

--
Ian Collins.
Nov 22 '06 #4
vamshi wrote:
>
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.

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Nov 22 '06 #5
Yes i need to keep structure definition opaque.

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

On Nov 22, 5:48 am, CBFalconer <cbfalco...@yahoo.comwrote:
vamshi wrote:
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.

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Nov 22 '06 #6
friend.05 wrote:
Yes i need to keep structure definition opaque.

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

On Nov 22, 5:48 am, CBFalconer <cbfalco...@yahoo.comwrote:
vamshi wrote:
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.

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
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?

Nov 22 '06 #7
"friend.05" wrote:
>
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:
<news:news.announce.newusers
<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/>

Nov 22 '06 #8
friend.05 wrote:
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.

Nov 22 '06 #9

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

Similar topics

22
by: Neo | last post by:
Hi Folks, #include<stdio.h> int main() { int (*p); int arr; int i;
1
by: dyu9999 | last post by:
Hi, I have a following error and would appreciate any help. ======================================================== * in foo.c I have typedef struct _my_data_t { int a;
204
by: Alexei A. Frounze | last post by:
Hi all, I have a question regarding the gcc behavior (gcc version 3.3.4). On the following test program it emits a warning: #include <stdio.h> int aInt2 = {0,1,2,4,9,16}; int aInt3 =...
5
by: Steven | last post by:
Hello, I get the following message during compilation: `dereferencing pointer to incomplete type' It stems from the compare function I use with qsort() and I am not quite sure how to fix it....
0
by: friend.05 | last post by:
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...
7
by: Travis | last post by:
I'm relatively new to externs and function pointers but have inherited the task of modifying some existing code. I have something like this. extern void myExternFunc (MenuItem *item, void *...
4
by: Pritam | last post by:
line 7: error: dereferencing pointer to incomplete type 1. #include<stdio.h> 2. #include<sys/stat.h> 3. #include<stdlib.h> 4. void execname() { 5. struct task_struct *my; 6. my =...
5
by: tejesh | last post by:
I am trying to compile the following code int backend_sm_run(struct interface_data *ctx) { xsup_assert((ctx != NULL), "ctx != NULL", TRUE); xsup_assert((ctx->statemachine != NULL),...
6
by: hnshashi | last post by:
I have written kernel(2.4) module to communicate with user application using "Netlink Socket". I am getting compilation error "Dereferencing pointer to incomplete type" in kernel module for "nlh...
5
by: Anuz | last post by:
Hi all, While compiling a driver, I am getting this error: error: dereferencing pointer to incomplete type int __kc_adapter_clean(struct net_device *netdev, int *budget) { /*some...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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...

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.