Thread: help needed with dereferencing pointer to incomplete type error

  1. #1
    Registered User ursula's Avatar
    Join Date
    May 2009
    Location
    Madrid, Spain
    Posts
    11

    help needed with dereferencing pointer to incomplete type error

    So heres my code:
    Code:
    char buf[256]; 
    struct rtp_hdr_t *header = (struct rtp_hdr_t *) buf;
    
    memset(buf,0,256); 
    header->version = 2;
    header->p = 0;
    header->x = 0;
    header->cc = 0;
    header->m = 0;
    header->pt = 0;
    header->seq = htons(0);
    header->ts = htons(0);
    Im getting the error in all the assignment lines.

    Heres rtp_hdr_t:
    Code:
    typedef struct {
    #if RTP_BIG_ENDIAN
        unsigned int version:2;   /* protocol version */
        unsigned int p:1;         /* padding flag */
        unsigned int x:1;         /* header extension flag */
        unsigned int cc:4;        /* CSRC count */
        unsigned int m:1;         /* marker bit */
        unsigned int pt:7;        /* payload type */
    #elif RTP_LITTLE_ENDIAN
        unsigned int cc:4;        /* CSRC count */
        unsigned int x:1;         /* header extension flag */
        unsigned int p:1;         /* padding flag */
        unsigned int version:2;   /* protocol version */
        unsigned int pt:7;        /* payload type */
        unsigned int m:1;         /* marker bit */
    #else
    #error Define one of RTP_LITTLE_ENDIAN or RTP_BIG_ENDIAN
    #endif
        unsigned int seq:16;      /* sequence number */
        u_int32 ts;               /* timestamp */
        u_int32 ssrc;             /* synchronization source */
        u_int32 csrc[1];          /* optional CSRC list */
    } rtp_hdr_t;
    Im honestly not very good working with pointers and i cant see where the problem is here. Pls help... Thanks!

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Your code defines nothing called "struct rtp_hdr_t". So you can't try to assign to such a thing, since it doesn't exist. (You do have such a thing as "rtp_hdr_t", though; maybe you could use that instead.)

  3. #3
    Registered User ursula's Avatar
    Join Date
    May 2009
    Location
    Madrid, Spain
    Posts
    11
    i do define the struct rtp_hdr_t. Thats the second part.


    Im not following what u mean....

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    The second part of your code defines nothing that is called "struct rtp_hdr_t". It does define a type called "rtp_hdr_t". Yes, there is a difference.

    Edit: To be more precise, this is "struct rtp_hdr_t":
    Code:
    struct rtp_hdr_t {
        stuff;
    };
    This is "rtp_hdr_t":
    Code:
    typedef struct {
        stuff;
    } rpt_hdr_t;

  5. #5
    Registered User ursula's Avatar
    Join Date
    May 2009
    Location
    Madrid, Spain
    Posts
    11
    It worked like a charm! thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  3. sorting the matrix question..
    By transgalactic2 in forum C Programming
    Replies: 47
    Last Post: 12-22-2008, 03:17 PM
  4. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  5. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM