接上文,修改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. cubieboardtruck安装

    1.命令关闭所有led灯 ls /sys/class/leds/*/brightness | xargs -i -n1 echo "echo 0 > {}" | sh 如果需 ...

  2. 利用程序将.jrxml导出为.jasper文件并用PDF显示(2)

    直接在Web项目中使用.jasper文件,其实在软件项目开发时,.jrxml文件经常修改,而且.jrxml还要在项目中进行保留备份,所以较为流行的做法是在项目中使用.jrxml来生成.jasper文件 ...

  3. 深入理解Azure自动扩展集VMSS(1)

    前文中已经详细介绍了如何配置和部署Azure的虚拟机扩展集VMSS进行自动扩展,但在实际使用过程当中,用户会出现更进一步使用的一些问题,VMSS基本扩展原理及怎么简单调试?如何进行手动扩展?怎么使用自 ...

  4. JDK PATH 和 CLASSPATH环境变量的作用及其配置

    (1)PATH环境变量的作用 在安装JDK程序之后,在安装目录下的bin目录中会提供一些开发Java程序时必备的工具程序. 对于Java的初学者,建议在命令符模式下使用这些工具程序编译运行Java程序 ...

  5. #define XBYTE ((unsigned char volatile xdata *) 0)

    今天在看别人的CAN总线程序的时候,突然发现了这么一句宏定义:#define XBYTE ((unsigned char volatile xdata *) 0),以前都没注意到过.后来查了一下,发现 ...

  6. 执行yiic webapp命令时报错:php.exe不是内部或外部命令,也不是可运行的程序

    在执行 yiic webapp ../abc 命令时报错: “php.exe”不是内部或外部命令,也不是可运行的程序 或批处理文件. 这是因为yiic批处理程序找不到php.exe的执行路径引起的. ...

  7. VirtualBox虚拟机无法选择桥接方式

    VirtualBox 装好之后默认的网络是NAT模式,但这种模式中虚拟机配置的IP和主机的不再同一网段内,无法获得和主机一样的局域网地位,更不可能从主机用远程桌面携带硬盘的方式远程控制.而最简便的方法 ...

  8. 24C01的IIC 讀寫的c51程式

    /*------------------------------------------------------------------------------ 為了安全起見,程式中很多NOP是冗餘的 ...

  9. 捆绑和缩小(BundleConfig.RegisterBundles) 第五章 : MVC中的使用 | {version}用法

    使用捆绑与 ASP.NET MVC 放缩法 在这一节我们将创建 ASP.NET MVC 项目,审查捆绑和缩小.首先,创建一个新的 ASP.NET MVC 互联网项目,命名为MvcBM ,而无需更改任何 ...

  10. hdu 1159 Common Subsequence(LCS最长公共子序列)

    Common Subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...