接上文,修改Makefile和config.mk中,.depend相关文件格式后继续编译。

四、tools文件夹的文件编译错误

错误告警如下【多行信息,请使用右侧滚动条查看】:

 gcc -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -idirafter /u-boot-2010.09/u-boot-2010.09/include 
-idirafter /u-boot-2010.09/u-boot-2010.09/include2 -idirafter /u-boot-2010.09/u-boot-2010.09/include
-I /u-boot-2010.09/u-boot-2010.09/lib/libfdt -I /u-boot-2010.09/u-boot-2010.09/tools
-DTEXT_BASE=0x11080000 -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES -ansi -o default_image.o default_image.c -c
In file included from fdt_host.h::,
from mkimage.h:,
from default_image.c::
../include/libfdt.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
../include/libfdt.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
../include/libfdt.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
../include/libfdt.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
../include/libfdt.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
../include/libfdt.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
../include/libfdt.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
../include/libfdt.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
../include/libfdt.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
../include/libfdt.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
../include/libfdt.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
../include/libfdt.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘struct’
../include/libfdt.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
../include/libfdt.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’
../include/libfdt.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’
../include/libfdt.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’
In file included from default_image.c:::
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint32_t’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint32_t’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint32_t’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint32_t’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint32_t’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint32_t’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint32_t’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint32_t’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint8_t’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint8_t’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint8_t’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint8_t’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘char’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint32_t’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ulong’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘uint32_t’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ulong’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ulong’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ulong’
/u-boot-2010.09/u-boot-2010.09/include/image.h::: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘const’
default_image.c: 在函数‘image_set_header’中:
default_image.c::: 警告:隐式声明函数‘image_set_magic’
default_image.c::: 警告:隐式声明函数‘image_set_time’
default_image.c::: 警告:隐式声明函数‘image_set_size’
default_image.c::: 警告:隐式声明函数‘image_set_load’
default_image.c::: 警告:隐式声明函数‘image_set_ep’
default_image.c::: 警告:隐式声明函数‘image_set_dcrc’
default_image.c::: 警告:隐式声明函数‘image_set_os’
default_image.c::: 警告:隐式声明函数‘image_set_arch’
default_image.c::: 警告:隐式声明函数‘image_set_type’
default_image.c::: 警告:隐式声明函数‘image_set_comp’
default_image.c::: 警告:隐式声明函数‘image_set_name’
default_image.c::: 警告:隐式声明函数‘image_set_hcrc’
/u-boot-2010.09/u-boot-2010.09/rules.mk:: recipe for target `default_image.o' failed
make[]: *** [default_image.o] Error
make[]: 离开目录“/u-boot-2010.09/u-boot-2010.09/tools”
Makefile:: recipe for target `tools' failed
make: *** [tools] Error

1、首先,需要了解gcc的错误告警信息。

1)错误位置:文件名:行号:列号。【注意:gcc工具的告警信息不是很友好,显示的错误位置可能不是真实的位置】

2)引用关系:错误提示中,第2~4行,表示头文件的引用关系(一层一层的引用)。

default_image.c 第30行 -- mkimage.h 第35行 -- fdt_host.h第25行-- libfdt.h

3)主要的错误类型: 错误:expected '=', ',', ';', 'asm' or '__attribute__' before

初步搜索,发现该问题和 头文件中 inline 关键字相关。

 GCC implements three different semantics of declaring a function inline. One is available with ‘-std=gnu89’ or ‘-fgnu89-inline’ or when gnu_inline attribute is present on all inline declarations, another when ‘-std=c99’ or ‘-std=gnu99’ (without ‘-fgnu89-inline’), and the third is used when compiling C++.
To declare a function inline, use the inline keyword in its declaration, like this:
static inline int inc (int *a)
{
(*a)++;
}
If you are writing a header file to be included in ISO C89 programs, write __inline__ instead of inline

2、从错误信息可以看到,gcc包含了参数 -ansi。

而 -ansi,对于gcc工具就等于 -std=c89。

在libfdt.h文件中,第162行如下

static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)

告警信息为第15列,void是错误的信息,gcc认为缺少 ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’

3、找到-ansi的位置并修改。

U-boot 编译工具相关的配置,都在主文件夹 config.mk文件中,

 ifeq ($(HOSTOS),cygwin)
HOSTCFLAGS += -ansi
endif

从配置中可以,u-boot认为在cygwin下,需要增加-ansi的编译选型。

但实际,由于u-boot-2010.09文件是根据C99规范编写的,应该删除该信息。

4、gcc工具编译错误的问题得到解决。

 gcc -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer  -idirafter /u-boot-2010.09/u-boot-2010.09/include  
-idirafter /u-boot-2010.09/u-boot-2010.09/include2 -idirafter /u-boot-2010.09/u-boot-2010.09/include
-I /u-boot-2010.09/u-boot-2010.09/lib/libfdt -I /u-boot-2010.09/u-boot-2010.09/tools
-DTEXT_BASE=0x11080000 -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES -pedantic -o img2srec.o img2srec.c -c
gcc -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -idirafter /u-boot-2010.09/u-boot-2010.09/include
-idirafter /u-boot-2010.09/u-boot-2010.09/include2 -idirafter /u-boot-2010.09/u-boot-2010.09/include
-I /u-boot-2010.09/u-boot-2010.09/lib/libfdt -I /u-boot-2010.09/u-boot-2010.09/tools
-DTEXT_BASE=0x11080000 -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES -pedantic -o img2srec img2srec.o
strip img2srec

可以看到正常生成了 img2srec.o

5、后记

C语言标准比较多,gcc支持的也比较多,相关关键字有:

gcc-4.5支持的C语言标准
1 -ansi In C mode, this is equivalent to ‘-std=c89’. In C++ mode, it is equivalent to ‘-std=c++’.
-std= Determine the language standard. A value for this option must be provided; possible values are
‘c89’
‘iso9899:’
Support all ISO C90 programs (certain GNU extensions that conflict
with ISO C90 are disabled). Same as ‘-ansi’ for C code.
‘iso9899:’
ISO C90 as modified in amendment .
    ‘c99’
    ‘c9x’
11     ‘iso9899:’
12     ‘iso9899:199x’
ISO C99. Note that this standard is not yet fully supported;
see http://gcc.gnu.org/gcc-4.3/c99status.html for more information.
The names ‘c9x’ and ‘iso9899:199x’ are deprecated.
‘gnu89’ GNU dialect of ISO C90 (including some C99 features). This is the default for C code.
17 ‘gnu99’
‘gnu9x’ GNU dialect of ISO C99. When ISO C99 is fully implemented in GCC, this will become the default.
The name ‘gnu9x’ is deprecated.
‘c++’ The ISO C++ standard plus amendments. Same as ‘-ansi’ for C++ code.
‘gnu++’ GNU dialect of ‘-std=c++’. This is the default for C++ code.
‘c++0x’ The working draft of the upcoming ISO C++0x standard. This option enables experimental features
that are likely to be included in C++0x. The working draft is constantly changing,
and any feature that is enabled by this flag may be removed from future versions of GCC
if it is not part of the C++0x standard.
‘gnu++0x’ GNU dialect of ‘-std=c++0x’. This option enables experimental features
that may be removed in future versions of GCC.

===【未完待续】===

基于cygwin构建u-boot(二)gcc的C语言标准版本号(-std=)的更多相关文章

  1. 基于cygwin构建u-boot(一)环境搭建

    从本文开始,更系统的描述基于cygwin构建u-boot. 之前<痛苦的版本对齐>系列,对于cygwin环境下Sourcery CodeBench,u-boot-1.1.6的构建有侧面的说 ...

  2. 基于cygwin构建u-boot(五)结尾:shell 工具

    结尾,基于cygwin对u-boot的处理,很大一部分都是再处理 路径等相关的问题,只有一个涉及到gcc的参数配置. 为了达到顺利编译的目的,使用shell下的部分工具进行处理. 1.sed sed简 ...

  3. 基于cygwin构建u-boot(四)libgcc引用

    接上文,config.mk文件修改后,即使没有.depend也可以正常处理了: 六.错误:gcclib引用错误 完成之前几篇的工作后,程序就可以一直执行了,直到最后生成u-boot, 出现如下错误告警 ...

  4. 基于cygwin构建u-boot(三)make错误忽视

    接上文,修改gcc 的-std标准后,.depend文件处理仍然出现了错误: 五.错误:make中命令报错(sed找不到需要的文件) 错误告警如下: make -C examples/api all ...

  5. Docker从入门到掉坑(二):基于Docker构建SpringBoot微服务

    本篇为Docker从入门到掉坑第二篇:基于Docker构建SpringBoot微服务,没有看过上一篇的最好读过 Docker 从入门到掉坑 之后,阅读本篇. 在之前的文章里面介绍了如何基于docker ...

  6. 三十二张图告诉你,Jenkins构建Spring Boot 有多简单~

    持续原创输出,点击上方蓝字关注我 目录 前言 如何安装Jenkins? 环境准备 开始安装Jenkins 初始化配置 访问首页 输入管理员密码 安装插件 创建管理员 实例配置 配置完成 构建Sprin ...

  7. 基于springboot构建dubbo的入门demo

    之前记录了构建dubbo入门demo所需的环境以及基于普通maven项目构建dubbo的入门案例,今天记录在这些的基础上基于springboot来构建dubbo的入门demo:众所周知,springb ...

  8. 基于Maven构建整合SpringMVC+Mybtis+Druid

    前几天趁空闲时间整合了下SpringMVC+Mybatis+Druid,这里小记录下,这个Demo是基于Maven构建的,数据源用的是阿里巴巴温少的开源项目Druid,数据库用的是Mysql. 由于E ...

  9. 基于kubernetes构建Docker集群管理详解-转

    http://blog.liuts.com/post/247/ 一.前言        Kubernetes 是Google开源的容器集群管理系统,基于Docker构建一个容器的调度服务,提供资源调度 ...

随机推荐

  1. 163k地方门户网站系统自动审核信息脚本

    本代码实现对163k地方门户网站系统发布信息的自动审核,以及对内容中链接全过滤 软件安装 Python 安装 http://www.python.org/download/ pymssql安装 htt ...

  2. centos 图形界面和命令行界面切换

    如果在图形界面下,按:Ctrl+Alt+F2进入命令行登录界面 切到root用户下, su root password 1, 关闭图形界面: init 3 关闭图形界面(XServer服务也会关闭) ...

  3. Visual studio 使用正则表达查找替换

    原文 http://www.cnblogs.com/shineqiujuan/archive/2012/07/04/2575535.html 正则表达式是查找和替换文本模式的一种简洁而灵活的表示法.  ...

  4. hdu 1853 最小费用流好题 环的问题

    Cyclic Tour Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/65535 K (Java/Others) Tota ...

  5. mybatis源代码分析:深入了解mybatis延迟加载机制

    下文从mybatis(3.2.7)延迟加载样例讲起,逐步深入其实现机制. 下面的例子是Student类关联一个Teacher对象,在访问Student对象时,不立即加载其关联的Teacher对象,而是 ...

  6. unix c 08

    信号 - signal()改变信号的处理方式.默认情况下,信号在Unix中都有自己的处理方式,如果想改变信号的处理方式,signal/sigaction 可以实现. 信号可以在关键代码处进行屏蔽,因为 ...

  7. UESTC_王之盛宴 2015 UESTC Training for Graph Theory<Problem K>

    K - 王之盛宴 Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit  ...

  8. Linux内存点滴 用户进程内存空间

    Linux内存点滴 用户进程内存空间 经常使用top命令了解进程信息,其中包括内存方面的信息.命令top帮助文档是这么解释各个字段的. VIRT, Virtual Image (kb) RES, Re ...

  9. hdu 4007 Dave(线性探查+枚举)

    Problem Description Recently, Dave is boring, so he often walks around. He finds that some places ar ...

  10. Qt creator自定义编译运行步骤

    一直用Qt creator开发.无它,只是因为linux下C++ IDE选择不多.同时因为我抛弃了MFC,平时写个小工具还得靠Qt,正好一举两用. 用Qt creator开发一般的工程,是不用修改编译 ...