"错误:数字常量之前的预期标识符"在生成的c文件中

时间:2015-07-15 06:04:44

标签: c

我正在尝试构建我的代码库,但我收到了错误

  

"错误:数字常量之前的预期标识符"

构建

时生成的c文件中的

,行号指rw_offsetof(struct __pthread_mutex_s,1),

sizeof( pthread_attr_t ),
sizeof(((pthread_attr_t *)RW_UE_NULL)->__size ),
sizeof( struct __pthread_internal_slist ),
rw_offsetof( struct __pthread_internal_slist, __next ),
sizeof( struct __pthread_mutex_s ),
rw_offsetof( struct __pthread_mutex_s, __lock ),
rw_offsetof( struct __pthread_mutex_s, __count ),
rw_offsetof( struct __pthread_mutex_s, __owner ),
rw_offsetof( struct __pthread_mutex_s, __kind ),
rw_offsetof( struct __pthread_mutex_s, __nusers ),
rw_offsetof( struct __pthread_mutex_s, 1 ),
sizeof( pthread_mutex_t ),
sizeof(((pthread_mutex_t *)RW_UE_NULL)->__size ),
sizeof( pthread_mutexattr_t ),
sizeof(((pthread_mutexattr_t *)RW_UE_NULL)->__size ),
sizeof( pthread_cond_t ),
sizeof(((pthread_cond_t *)RW_UE_NULL)->__size ),
sizeof( pthread_condattr_t ),
sizeof(((pthread_condattr_t *)RW_UE_NULL)->__size ),
sizeof( sem_t ),
sizeof(((sem_t *)RW_UE_NULL)->__size ),

我发现__pthread_mutex_s是在pthreadtypes.h中定义的

typedef union  
{  
  struct  __pthread_mutex_s  
  {  
    int __lock;  
    unsigned int __count;  
    int __owner;  
    int __kind;  
    unsigned int __nusers;  
    __extension__ union  
    {  
      int __spins;  
      __pthread_slist_t __list;  
    };  
  } __data;  
  char __size[__SIZEOF_PTHREAD_MUTEX_T];  
  long int __align;  
} pthread_mutex_t;  

因为这是系统文件,这怎么会导致问题?

1 个答案:

答案 0 :(得分:1)

rw_offsetof的第二个参数应该是第一个参数中命名的struct中字段的名称。第1367行中的用法看起来是正确的,但在第1368行中,你有文字常量1而不是字段的名称,因此错误。

如果没有更多的上下文,很难说出这个错误是如何发生的,但我最好的猜测是你有一个预处理器宏,其名称与__pthread_mutex_s中的字段同名(例如{{ 1}}或__count),此宏为__list d为#define

相关问题