基于cygwin构建u-boot(二)gcc的C语言标准版本号(-std=)
接上文,修改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=)的更多相关文章
- 基于cygwin构建u-boot(一)环境搭建
从本文开始,更系统的描述基于cygwin构建u-boot. 之前<痛苦的版本对齐>系列,对于cygwin环境下Sourcery CodeBench,u-boot-1.1.6的构建有侧面的说 ...
- 基于cygwin构建u-boot(五)结尾:shell 工具
结尾,基于cygwin对u-boot的处理,很大一部分都是再处理 路径等相关的问题,只有一个涉及到gcc的参数配置. 为了达到顺利编译的目的,使用shell下的部分工具进行处理. 1.sed sed简 ...
- 基于cygwin构建u-boot(四)libgcc引用
接上文,config.mk文件修改后,即使没有.depend也可以正常处理了: 六.错误:gcclib引用错误 完成之前几篇的工作后,程序就可以一直执行了,直到最后生成u-boot, 出现如下错误告警 ...
- 基于cygwin构建u-boot(三)make错误忽视
接上文,修改gcc 的-std标准后,.depend文件处理仍然出现了错误: 五.错误:make中命令报错(sed找不到需要的文件) 错误告警如下: make -C examples/api all ...
- Docker从入门到掉坑(二):基于Docker构建SpringBoot微服务
本篇为Docker从入门到掉坑第二篇:基于Docker构建SpringBoot微服务,没有看过上一篇的最好读过 Docker 从入门到掉坑 之后,阅读本篇. 在之前的文章里面介绍了如何基于docker ...
- 三十二张图告诉你,Jenkins构建Spring Boot 有多简单~
持续原创输出,点击上方蓝字关注我 目录 前言 如何安装Jenkins? 环境准备 开始安装Jenkins 初始化配置 访问首页 输入管理员密码 安装插件 创建管理员 实例配置 配置完成 构建Sprin ...
- 基于springboot构建dubbo的入门demo
之前记录了构建dubbo入门demo所需的环境以及基于普通maven项目构建dubbo的入门案例,今天记录在这些的基础上基于springboot来构建dubbo的入门demo:众所周知,springb ...
- 基于Maven构建整合SpringMVC+Mybtis+Druid
前几天趁空闲时间整合了下SpringMVC+Mybatis+Druid,这里小记录下,这个Demo是基于Maven构建的,数据源用的是阿里巴巴温少的开源项目Druid,数据库用的是Mysql. 由于E ...
- 基于kubernetes构建Docker集群管理详解-转
http://blog.liuts.com/post/247/ 一.前言 Kubernetes 是Google开源的容器集群管理系统,基于Docker构建一个容器的调度服务,提供资源调度 ...
随机推荐
- [LA] 2031 Dance Dance Revolution
Dance Dance Revolution Time limit: 3.000 seconds Mr. White, a fat man, now is crazy about a game nam ...
- Liunx+C编程一站式学习
Liunx+C编程一站式学习这本书有什么特点?面向什么样的读者?这本书最初是为某培训班的嵌入式系统Linux工程师就业班课程量身定做的教材之一.该课程是为期四个月的全日制职业培训,要求学员毕业时具备非 ...
- 163k地方门户网站系统团购定时结束限量控制
#coding=utf8 #!/usr/bin/env python # 网站自动审核系统 import pymssql import re import sys import datetime im ...
- Keil C51处理可重入函数问题的探讨
在程序设计中,变量具体可以分为四种类型:全局变量.静态全局变量.局部变量.静态局部变量.这几种变量类型对函数的可重入产生的重大的影响,因为不同的编译器采用不同的策略. 针对51的存储区有限,keil ...
- fragment中嵌套viewpager,vierpager中有多个fragment,不显示 .
fragment中嵌套viewpager,vierpager中有多个fragment,不显示 ... 现在好多应用流行一种布局.底部几个工具栏选项,上面也有类似tab的选项. 底部用RadioGrou ...
- javascript遍历Json对象个数
var data={}; for (var d in data) { $(data[d]).each(function (i, e) { aler ...
- Java通过JNI调用C/C++
From:http://www.cnblogs.com/mandroid/archive/2011/06/15/2081093.html JNI是JAVA标准平台中的一个重要功能,它弥补了JAVA的与 ...
- Hdu3812-Sea Sky(深搜+剪枝)
Sea and Sky are the most favorite things of iSea, even when he was a small child. Suzi once wrote: ...
- 《Algorithms 4th Edition》读书笔记——3.1 符号表(Elementary Symbol Tables)-Ⅲ
3.1.3 用例举例 在学习它的实现之前我们还是应该先看看如何使用它.相应的我们这里考察两个用例:一个用来跟踪算法在小规模输入下的行为测试用例和一个来寻找更高效的实现的性能测试用例. 3.1.3.1 ...
- devStack for Openstack dev Env
devstack是一套用来给开发人员快速部署Openstack开发环境的脚本,其实对于整个安装过程没有什么好说的,因为脚本写的很完善,全程无脑式安装也没什么大问题,但是因为公司里的网络环境不给力,我的 ...