473,387 Members | 1,520 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,387 software developers and data experts.

dereferencing pointer to incomplete type2

Hello all of u .. well i was trying to compile the iscsi module over ma system whn i was faced with this error .. the code segment is as under

Expand|Select|Wrap|Line Numbers
  1. int
  2. cnv_inet_to_string(struct sockaddr *ip_address, char *ip_string,
  3.            char *port_string)
  4. {
  5.     __u8 *ptr;
  6.     __u32 k;
  7.     int i, c;
  8.  
  9.     if (ip_address == NULL) {
  10.         i = -EINVAL;
  11.     } else if (ip_address->sa_family == AF_INET) 
  12.     {
  13.         ptr = (__u8 *)&((struct sockaddr_in *)ip_address)->sin_addr.s_addr;  //Dereferencing Pointer to incompete type
  14.         for (i = 0; i < 3; i++) {
  15.             ip_string += sprintf(ip_string, "%u.", *ptr++);
  16.         }
  17.         sprintf(ip_string, "%u", *ptr);
  18.         sprintf(port_string, "%u",
  19.             ntohs(((struct sockaddr_in *)ip_address)->sin_port));
  20.         i = AF_INET;
  21.     } else if (ip_address->sa_family == AF_INET6) {
  22.         ptr = (__u8 *)((struct sockaddr_in6 *)ip_address)
  23.             ->sin6_addr.s6_addr;
  24.         c = '[';
  25.         for (i = 0; i < 8; i++ ) {
  26.             k = *ptr++ << 8;
  27.             k += *ptr++;
  28.             ip_string += sprintf(ip_string, "%c%x", c, k);
  29.             c = ':';
  30.         }
  31.         sprintf(ip_string, "]");
  32.         sprintf(port_string, "%u",
  33.             ntohs(((struct sockaddr_in6 *)ip_address)->sin6_port));
  34.         i = AF_INET6;
  35.     } else {
  36.         strcpy(ip_string, "Unknown protocol family");
  37.         i = -EPFNOSUPPORT;
  38.     }
  39.     return i;
  40. }
  41.  
So some1 plzz suggest me wat shd i do to get rid of this **** ....
Oct 19 '08 #1
3 2103
_u8 *ptr;
ptr = (__u8 *)&((struct sockaddr_in *)ip_address)->sin_addr.s_addr;

Why is this showing dereferencing pointer to incomplete type????
Oct 19 '08 #2
JosAH
11,448 Expert 8TB
@shridharpandey: I split your posts from the old thread you posted your questions
in; don't hijack other threads for your question, no matter how old they are and
no matter how similar your question is to another question. Also add code tags
around your code for readability reasons. And please use proper spelling if you
want to be taken seriously.

kind regards,

Jos

ps. I added those code tags for you this time.
Oct 19 '08 #3
Banfa
9,065 Expert Mod 8TB
Also note that we don't allow swearing on this site, please read our posting guidelines.


Dereference to an incomplete type usually means that the compiler is aware that a structure of a given name exists but has no visibility of that structure of that structure. This most often happens when a structure name is forward declared and then the header the structure is defined in is accidentally not included.

For example suppose the file Example.h contains the following

Expand|Select|Wrap|Line Numbers
  1. #ifndef EXAMPLE_H_INCLUDED
  2. #define EXAMPLE_H_INCLUDED
  3.  
  4. struct Example {
  5.     int someData;
  6. };
  7.  
  8. #endif
  9.  
Then suppose a file main.c contained the following

Expand|Select|Wrap|Line Numbers
  1. struct Example; // Forward declaration of struct Example
  2.  
  3. extern Example *GetExample();
  4. extern void ReleaseExample(Example *ex);
  5.  
  6. int main(int argc, char *argp[])
  7. {
  8.     Example *ex = GetExample();
  9.  
  10.     ex->someData = 6;
  11.  
  12.     ReleaseExample(ex);
  13.  
  14.     return 0;
  15. }
  16.  
Supposing that GetExample and ReleaseExample are defined in another file somewhere you would get a 'dereferencing pointer to incomplete' type error on line 10. This would be solved by including the file with the declaration of struct Example rather than forward declaring it.
Oct 19 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: junky_fellow | last post by:
Can the size of pointer variables of different type may be different on a particular architecture. For eg. Can the sizeof (char *) be different from sizeof(int *) or sizeof (void *) ? What...
10
by: junky_fellow | last post by:
K&R say that, It is guaranteed that 1) a pointer to an object may be converted to a pointer to an object whose type requires less or equally strict storage alignment and 2) back again without...
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...
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 =...
3
by: Kufa | last post by:
Hi, I have nailed down a piece of code that is obviously wrong, but cannot find what i should i do to make it ansi compliant, neither where in the reference i should look. Basically i m trying...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.