![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Creating a pointer to std::istrstream is giving error | khan_069 | AIX | 0 | 09-10-2008 03:24 AM |
| error: field `fatx_i' has incomplete type | lateralus01 | High Level Programming | 2 | 07-22-2008 02:02 AM |
| error: field has incomplete type | boyanov | High Level Programming | 4 | 08-10-2007 04:15 AM |
| array type has incomplete element type | jaganadh | High Level Programming | 1 | 07-24-2007 03:54 AM |
| Accesing structure member:Error:dereferencing pointer to incomplete type | amit4g | High Level Programming | 3 | 05-07-2007 08:32 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I'm getting the following Error:
prepare_pcap.c: In function `prepare_pkts': prepare_pcap.c:127: error: dereferencing pointer to incomplete type prepare_pcap.c:138: error: dereferencing pointer to incomplete type ==================================== This is the part of the relevant Code: -----PREPARE_PCAP.H----------- #if defined(__HPUX) || defined(__DARWIN) || defined(__CYGWIN) || defined(__FreeBSD__) struct iphdr { #ifdef _HPUX_LI unsigned int ihl:4; unsigned int version:4; #else unsigned int version:4; unsigned int ihl:4; #endif u_int8_t tos; u_int16_t tot_len; u_int16_t id; u_int16_t frag_off; u_int8_t ttl; u_int8_t protocol; u_int16_t check; u_int32_t saddr; u_int32_t daddr; /*The options start here. */ }; ------PREPARE_PCAP.C--------- int prepare_pkts(char *file, pcap_pkts *pkts) { pcap_t *pcap; struct pcap_pkthdr *pkthdr = NULL; ..... struct iphdr *iphdr; ..... iphdr = (struct iphdr *)((char *)ethhdr + sizeof(*ethhdr)); <<<LINE 127 if (iphdr && iphdr->version == 6) { //ipv6 pktlen = (u_long) pkthdr->len - sizeof(*ethhdr) - sizeof(*ip6hdr); ---------------------------- This is where the error occurs. Can anyone please give me suggestion? Thank you in Advance. |
|
||||
|
Build Error: error: dereferencing pointer to incomplete type
Thank you for your reply. First a background on what I'm trying to do - I'm trying to compile SIPp (VoIP load generator) on Solaris Platform. This is an open Source code - however, a majority of the usage is on Linux platform - where it compiles fine.
I tried your suggestion of replacing sizeof((ethhdr) with sizeof( struct ethhdr ) - however, it fails with the following error: prepare_pcap.c:126: error: invalid application of `sizeof' to an incomplete type Source Line 126: iphdr = (struct iphdr *)((char *)ethhdr + sizeof(struct ethhdr)); Please let me know if you have other suggestions. thank you, -------------------------------------------------- |
|
|||||
|
omg -- this is actual open source code? that's amazing.
Well -- one error at a time. Fix one -- on to the next. That first suggestion did what it was supposed to do. This statement: Code:
iphdr = (struct iphdr *)((char *)ethhdr + sizeof(struct ethhdr)); jumping over the size of itself and assuming that the next spot in memory is a pointer to iphdr. This simply is dreaming. Although it ~could~ happen, given that the compiler writer places his variables on after the other in memory but if it did... that means that the memory must've been explicitly declared somewhere and if so... why not explicitly cast that memory here? But whatever. The same problem exists, more or less. But to get it to compile, try this: Code:
iphdr = (struct iphdr *)((long)ðhdr + (long)sizeof(struct ethhdr)); Code:
iphdr = (void *)((long)ðhdr + (long)sizeof(struct ethhdr)); |
|
||||
|
Modified your suggestion to:
iphdr = (void *)((long)ðhdr + (long)sizeof(ðhdr)); And I don't see the error : prepare_pcap.c:127: error: invalid application of `sizeof' to an incomplete type -------- Any suggestion on the original error : dereferencing pointer to incomplete type. thx. |
|
|||||
|
why modify my suggestion and then complain when it doesn't work?
Here is how this stuff is supposed to work: Code:
#include <stdio.h>
#include <string.h>
struct hdr {
int x;
long y;
char z[16];
};
struct hdr *iphdr;
struct hdr ethhdr;
int main()
{
ethhdr.x = 7;
ethhdr.y = 81;
strcpy( ethhdr.z, "frogs" );
iphdr = (void *)((long)ðhdr + (long)sizeof(ðhdr));
(void)printf( "address becomes: |%x|\n", ðhdr );
(void)printf( "address becomes: |%x|\n", iphdr );
return 0;
}
Code:
address becomes: |20e54| address becomes: |20e58| Code:
iphdr = (void *)((long)ðhdr + (long)sizeof(ðhdr)); it is a bug. it's wrong. etc... |
|
||||
|
I forgot one thing: I had tried w/ ur suggestion:
iphdr = (struct iphdr *)((long)ðhdr + (long)sizeof(struct ethhdr)); and also with iphdr = (void *)((long)ðhdr + (long)sizeof(struct ethhdr)); However, I got this error again: prepare_pcap.c:127: error: invalid application of `sizeof' to an incomplete type |
![]() |
| Bookmarks |
| Tags |
| build error |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|