Gaurav Pathak
Gaurav Pathak

Reputation: 13

Typedef an externel structure in file using cross-compiler (arm-none-eabi-gcc)

I'm trying to compile a project which consist of severel source fies & header files & includes some structure definiton. But when I compile an error comes

"error: expected specifier-qualifier-list before 'typedef'" in file "uip.h"

I have a structure in file named as "httpd.h"

    struct httpd_state {
    unsigned char timer;
    struct psock sin, sout;
    struct pt outputpt, scriptpt;
    char inputbuf[50];
    char filename[20];
    char state;
    struct httpd_fsdata_file_noconst *file;
    int len;
    char *scriptptr;
    int scriptlen;
    unsigned short count;
    };

I want to typedef this structure in another file named as "uip.h"

    struct uip_conn {
    uip_ipaddr_t ripaddr;   /**< The IP address of the remote host. */
    u16_t lport;        /**< The local TCP port, in network byte order. */
    u16_t rport;        /**< The local remote TCP port, in network order. */
    u8_t rcv_nxt[4];    /**< The sequence number that we expect toreceive next. */
    u8_t snd_nxt[4];    /**< The sequence number that was last sent by us. */
    u16_t len;          /**< Length of the data that was previously sent. */
    u16_t mss;          /**< Current maximum segment size for the connection. */
    u16_t initialmss;   /**< Initial maximum segment size for the connection. */
    u8_t sa;            /**< Retransmission time-out calculation state variable. */
    u8_t sv;            /**< Retransmission time-out calculation state variable. */
    u8_t rto;           /**< Retransmission time-out. */
    u8_t tcpstateflags; /**< TCP state and flags. */
    u8_t timer;         /**< The retransmission timer. */
    u8_t nrtx;          /**< The number of retransmissions for the last segment sent*/
  /** The application state. */
   **typedef struct httpd_state uip_tcp_appstate_t;
   uip_tcp_appstate_t appstate;**
   } __attribute__((packed));

Can anyone please help??

Upvotes: 1

Views: 330

Answers (1)

Adam Rosenfield
Adam Rosenfield

Reputation: 400454

You can't have a typedef statement inside a struct definition. Either hoist it outside of the struct, or don't use the typedef at all:

// Option #1: Hoisting
typedef struct httpd_state uip_tcp_appstate_t;
struct uip_conn {
    ...
    uip_tcp_appstate_t appstate;
};

// Option #2: No typedef
struct uip_conn {
    ...
    struct httpd_state appstate;
};

Upvotes: 3

Related Questions