1

深刻なソースファイルとヘッダーファイルで構成され、いくつかの構造定義を含むプロジェクトをコンパイルしようとしています。しかし、コンパイルするとエラーが発生します

「エラー: 'typedef' の前に指定子修飾子リストが必要です」ファイル「uip.h」

「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;
    };

「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));

誰でも助けてもらえますか??

4

1 に答える 1

3

定義typedef内にステートメントを含めることはできません。structの外側に持ち上げるか、 をstructまったく使用しないでくださいtypedef

// 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;
};
于 2013-09-16T19:19:36.613 に答える