C 编译错误-分析错误和类型不完整

C 编译错误-分析错误和类型不完整,c,gcc,struct,compilation,C,Gcc,Struct,Compilation,我正在使用gcc-3.3.4。我在做的是假装什么。 当我使用gcc-O0-g-fomit frame pointer-I/usr/src/kernel-headers-2.4.26-1/include sleep.c-o sleep.exe编译文件时 我遇到以下问题: msync-sleep.c:47: error: parse error before "wait_queue_head_t" msync-sleep.c:47: warning: no semicolon at end of s

我正在使用gcc-3.3.4。我在做的是假装什么。 当我使用gcc-O0-g-fomit frame pointer-I/usr/src/kernel-headers-2.4.26-1/include sleep.c-o sleep.exe编译文件时 我遇到以下问题:

msync-sleep.c:47: error: parse error before "wait_queue_head_t"
msync-sleep.c:47: warning: no semicolon at end of struct or union
msync-sleep.c:81: error: field `i_sem' has incomplete type
msync-sleep.c:83: error: field `i_zombie' has incomplete type
msync-sleep.c:87: error: parse error before "wait_queue_head_t"
msync-sleep.c:87: warning: no semicolon at end of struct or union
msync-sleep.c:90: error: parse error before '}' token
msync-sleep.c:93: error: parse error before "atomic_t"
msync-sleep.c:93: warning: no semicolon at end of struct or union
msync-sleep.c:96: error: parse error before '}' token
msync-sleep.c:103: error: parse error before "atomic_t"
msync-sleep.c:103: warning: no semicolon at end of struct or union
msync-sleep.c:105: error: parse error before '}' token
msync-sleep.c:149: error: field `fake_dentry' has incomplete type
msync-sleep.c:150: error: field `fake_inode' has incomplete type
msync-sleep.c:151: error: field `fake_mapping' has incomplete type
msync-sleep.c:152: error: field `fake_ops' has incomplete type
msync-sleep.c:153: error: field `dirty_page' has incomplete type
我认为问题来自我的定义部分。这是我代码的一部分:

#include <stdio.h>      /* fprintf */
#include <stdlib.h>     /* exit */
#include <string.h>     /* memset */
#include <sys/mman.h>       /* mmap */
#include <sys/types.h>      /* pthread types */
#include <sys/stat.h>       /* fchmod */
#include <pthread.h>        /* thread primitives */
#include <fcntl.h>      /* open */
#include <unistd.h>     /* ftruncate */
#include <errno.h>      /* errno */

#include "linux/elf.h"      /* for elf struct defs */

#include "asm-i386/unistd.h"    /* uselib system call */
#include "asm-i386/page.h"      /* PAGE_SIZE */

#define LIB_ADDR   0xaabbccdd   /* memorable random address */
#define LIB_FILE   "sleepylib"
#define UNMAP_FILE "unmapfile"

/* --------------------------------------------------------
   fake struct defs
   -------------------------------------------------------- */
/* all of these only go as far as the last field we need to access */

struct list_head {
  struct list_head      *next;
  struct list_head      *prev;
};

struct wait_queue_head_t {
  volatile unsigned int lock;
  struct list_head      task_list;
};

struct semaphore {
  volatile int          count;
  int                   sleepers;
  wait_queue_head_t     wait;
};

struct rw_semaphore {
  signed long           count;
  volatile unsigned int wait_lock;
  struct list_head      wait_list;
};

struct inode {
  struct list_head      i_hash;
  struct list_head  i_list;
  struct list_head  i_dentry;

  struct list_head  i_dirty_buffers;
  struct list_head  i_dirty_data_buffers;

  unsigned long     i_ino;
  volatile int      i_count;
  unsigned short    i_dev;
  unsigned short    i_mode;
  unsigned short    i_nlink;
  unsigned short    i_uid;
  unsigned short    i_gid;
  unsigned short    i_rdev;
  long long     i_size;
  long          i_atime;
  long          i_mtime;
  long          i_ctime;
  unsigned int      i_blkbits;
  unsigned long     i_blksize;
  unsigned long     i_blocks;
  unsigned long     i_version;
  unsigned short        i_bytes;
  struct semaphore  i_sem;
  struct rw_semaphore   i_alloc_sem;
  struct semaphore  i_zombie;
  void  *i_op;
  void  *i_fop; 
  void  *i_sb;
  wait_queue_head_t i_wait;
  void  *i_flock;
  struct address_space  *i_mapping;
};

struct dentry {
  atomic_t d_count;
  unsigned int d_flags;
  struct inode *d_inode;
};

struct page {
  struct list_head list;        
  struct address_space *mapping;    
  unsigned long index;      
  struct page *next_hash;       
  atomic_t count;           
  unsigned long flags;      
};

struct fakes {
  /* dentry */
  struct dentry fake_dentry;
  struct inode fake_inode;
  struct address_space fake_mapping;
  struct address_space_operations fake_ops;
  struct page dirty_page;
};

提前感谢您的时间。

根据wait\u queue\u head\t可能是一个关键字,所以请尝试将其更改为其他内容。

谢谢您的回复@Nishant。我试着把它改成其他的东西,比如wait_me,但那一行出现了同样的错误。我把它改名为abc,那些错误就消失了。由于缺少文件asm-i386/unistd.h和asm-i386/page.h,我确实遇到了一些错误,但在删除类型atomic_t和struct address_space后,我能够编译,我希望这些文件中都有我很抱歉打扰您,但是您是否尝试过使用gcc-3.3.4和-I/usr/src/kernel-headers-2.4.26-1/include?Hi@Nishant我想我已经找到了其中一个问题的根源。在struct信号量的定义中,我应该使用struct wait\u queue\u head\u t wait;而不是排队等待;