Thread: help me with C codes

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    569

    help me with C codes

    I have the following struct defined:

    Code:
    typedef struct FrameHdr {
        u_char	type;		/* SSWP_DATA or SSWP_ACK */
        SeqNum	seq;		/* sequence number */
        u_char	size;		/* size of payload */
        u_char	flags;		/* see below */
    } FrameHdr;
    
    
    typedef struct Frame {
        FrameHdr	hdr;		/* Frame header */
        u_char	body[256];	/* Body */
    } Frame;
    and in my .c file I have the following:

    Code:
    Frame frame;
    frame.hdr.size = ....;
    frame.hdr.type = ....;
    frame.hdr.seq = ....;
    however I got these errors:

    sender.c:180: error: âFrameHdrâ has no member named âtypeâ
    sender.c:181: error: âFrameHdrâ has no member named âseqâ
    sender.c:181: error: âFrameHdrâ has no member named âsizeâ

    what am I doing wrong here?

  2. #2
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    404
    Looks fine to me. Are you sure that the structs you have shown are within the scope of the function you are trying to work with?

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    569
    the structs are declared on another .h file which I already included in the header of the .c file,. I also tried the following alternative, but it doesn't work as well

    Code:
    Frame* frame = (Frame*) malloc(sizeof(Frame));
    frame->hdr->type = TYPE_DATA;
    frame->hdr->seq = (SeqNum) LFS;
    frame->hdr->size = 0;

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    check the header guards - that they are unique in each homemade header

    if headers are from some library - check maybe some defines are needed, that will modify FrameHdr definition
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. codes
    By IfYouSaySo in forum A Brief History of Cprogramming.com
    Replies: 34
    Last Post: 11-18-2005, 03:09 PM
  2. Replies: 1
    Last Post: 07-12-2005, 09:03 PM
  3. action replay codes
    By c++.prog.newbie in forum Game Programming
    Replies: 2
    Last Post: 02-28-2004, 08:47 AM
  4. anyone have linked-list sample codes?
    By ling in forum C++ Programming
    Replies: 3
    Last Post: 07-03-2002, 02:24 PM