简体   繁体   English

GCC无法编译正确的代码

[英]GCC fails to compile correct code

I'm trying to compile uClibc 0.9.33.2 for my old router with Ubicom IP7k processor. 我正在尝试使用Ubicom IP7k处理器为旧路由器编译uClibc 0.9.33.2 Since it's architecture isn't officially supported by neither GCC nor uClibc, I have to port it myself and use a modified version of GCC ( ubicom32-uclinux-gcc (GCC) 4.4.1 20100320 (stable) ) from processor's vendor. 由于GCC和uClibc均未正式支持其体系结构,因此我必须自己移植并使用处理器供应商提供的GCC的修订版( ubicom32-uclinux-gcc (GCC) 4.4.1 20100320 (stable) )。 Everything was compiling fine, until GCC showed me a weird error. 一切都编译良好,直到GCC向我显示了一个奇怪的错误。

  CC libc/sysdeps/linux/common/fstatat.os
In file included from libc/sysdeps/linux/common/xstatconv.h:26,
                 from libc/sysdeps/linux/common/fstatat.c:11:
./include/bits/kernel_stat.h:25: error: expected ':', ',', ';', '}' or '__attribute__' before '.' token
./include/bits/kernel_stat.h:52: error: expected ':', ',', ';', '}' or '__attribute__' before '.' token
make: *** [libc/sysdeps/linux/common/fstatat.os] Error 1

kernel_stat.h: kernel_stat.h:

#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H

#ifndef _LIBC
#error bits/kernel_stat.h is for internal uClibc use only!
#endif

/* This file provides whatever this particular arch's kernel thinks 
 * struct kernel_stat should look like...  It turns out each arch has a 
 * different opinion on the subject... */

struct kernel_stat {
    unsigned short st_dev;
    unsigned short __pad1;
    unsigned long st_ino;
    unsigned short st_mode;
    unsigned short st_nlink;
    unsigned short st_uid;
    unsigned short st_gid;
    unsigned short st_rdev;
    unsigned short __pad2;
    unsigned long  st_size;
    unsigned long  st_blksize;
    unsigned long  st_blocks;
    unsigned long  st_atime;            <-- error occurs here
    unsigned long  __unused1;
    unsigned long  st_mtime;
    unsigned long  __unused2;
    unsigned long  st_ctime;
    unsigned long  __unused3;
    unsigned long  __unused4;
    unsigned long  __unused5;
};

struct kernel_stat64 {
    unsigned char   __pad0[6];
    unsigned short  st_dev;
    unsigned char   __pad1[4];
#define _HAVE_STAT64___ST_INO
    unsigned long   __st_ino;
    unsigned int    st_mode;
    unsigned int    st_nlink;
    unsigned long   st_uid;
    unsigned long   st_gid;
    unsigned char   __pad2[6];
    unsigned short  st_rdev;
    unsigned char   __pad3[4];
    long long   st_size;
    unsigned long   st_blksize;
    unsigned long   st_blocks;  /* Number 512-byte blocks allocated. */
    unsigned long   __pad4;     /* future possible st_blocks high bits */
    unsigned long   st_atime;           <-- and here
    unsigned long   __pad5;
    unsigned long   st_mtime;
    unsigned long   __pad6;
    unsigned long   st_ctime;
    unsigned long   __pad7;     /* will be high 32 bits of ctime someday */
    unsigned long long  st_ino;
};

#endif  /*  _BITS_STAT_STRUCT_H */

What exactly goes wrong here and is there any way to fix it without having to update GCC? 这里到底出了什么问题,有什么办法可以解决而不必更新GCC?

st_atime , etc. cannot be members of struct stat . st_atime等不能是struct stat成员。 Instead they are macros that expand to st_atim.tv_sec , etc. (note the lack of final e ), and st_atim etc. are members with type struct timespec . 相反,它们是扩展为st_atim.tv_sec等的宏(注意缺少final e ),而st_atim等则是struct timespec类型的成员。 The kernel has this wrong and just recreates the same layout flat in its notion of struct stat but you have to do it in a way that's correct for userspace. 内核有此错误,只是按照其struct stat概念重新创建了相同的布局平面,但是您必须以一种对用户空间正确的方式来执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM