接上文,修改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. 异步编程设计模式Demo - AsyncComponentSample

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.C ...

  2. 九章算法系列(#3 Binary Tree & Divide Conquer)-课堂笔记

    前言 第一天的算法都还没有缓过来,直接就进入了第二天的算法学习.前一天一直在整理Binary Search的笔记,也没有提前预习一下,好在Binary Tree算是自己最熟的地方了吧(LeetCode ...

  3. 转载----给JavaScript初学者的24条最佳实践

      给JavaScript初学者的24条最佳实践 1.使用 === 代替 == JavaScript 使用2种不同的等值运算符:===|!== 和 ==|!=,在比较操作中使用前者是最佳实践. “如果 ...

  4. 学习ReactNative笔记整理一___JavaScript基础

    学习ReactNative笔记整理一___JavaScript基础 ★★★笔记时间- 2017-1-9 ★★★ 前言: 现在跨平台是一个趋势,这样可以减少开发和维护的成本.第一次看是看的ReactNa ...

  5. 如何判断是REQUEST请求是来自移动终端还是来自PC端

    public bool IsMoblie()        {            string agent = (Request.UserAgent + "").ToLower ...

  6. Game of Life 解答

    Question According to the Wikipedia's article: "The Game of Life, also known simply as Life, is ...

  7. Java Fuck Bignumber

    为了熟悉java , 开一套poj大数处理的题来写. ------------------------------------------------------------------- A: (1 ...

  8. wireshark使用心得

    关于pcap文件的文件解析网上资料有很多,我在这就不说明了 心得一:wireshark Runtime Error 一般来说,wireshark不适合长时间捕获包,也就是随着时间增长,总会报出上述错误 ...

  9. [置顶] vi、akw和sed总结

  10. AFN的二次封装

    http://www.cnblogs.com/sxwangjiadong/p/4970751.html