标准
ANSI C:这一标准是 ANSI(美国国家标准局)于 1989 年制定的 C 语言标准。后来被 ISO(国际标准化组织)接受为标准,因此也称为 ISO C。
ANSI C 的目标是为各种操作系统上的 C 程序提供可移植性保证,而不仅仅限于 UNIX。 该标准不仅定义了 C 编程语言的语发和语义,而且还定义了一个标准库。这个库可以根据 头文件划分为 15 个部分,其中包括:字符类型 (<ctype.h>)、错误码 (<errno.h>)、 浮点常数 (<float.h>)、数学常数 (<math.h>)、标准定义 (<stddef.h>)、 标准 I/O (<stdio.h>)、工具函数 (<stdlib.h>)、字符串操作 (<string.h>)、 时间和日期 (<time.h>)、可变参数表 (<stdarg.h>)、信号 (<signal.h>)、 非局部跳转 (<setjmp.h>)、本地信息 (<local.h>)、程序断言 (<assert.h>) 等等。
POSIX:该标准最初由 IEEE 开发的标准族,部分已经被 ISO 接受为国际标准。该标准的具体内容 见 1.1.3。POSIX.1 和 POSIX.2 分别定义了 POSIX 兼容操作系统的 C 语言系统接口 以及 shell 和工具标准。这两个标准是通常提到的标准。
SVID:System V 的接口描述。System V 接口描述(SVID)是描述 AT&&;T Unix System V 操作 系统的文档,是对 POSIX 标准的扩展超集。
XPG:X/Open 可移植性指南。X/Open 可移植性指南(由 X/Open Company, Ltd.出版), 是比 POSIX 更为一般的标准。X/Open 拥有 Unix 的版权,而 XPG 则指定成为 Unix 操作系统必须满足的要求。
---------------------------------------
GCC所支持的后缀名的解释
.c C原始程序
.C/.cc/.cxx
C++原始程序
.m
Object C原始程序
.i
已经过预处理的C原始程序
.ii
已经过预处理的C++原始程序
.s/.S
汇编语言原始程序
.h
预处理文件(头文件)
.o
目标文件
.a/.so
编译后的库文件
int main()
{
}
[armlinux@lqm program]$ gcc -E hello.c -o hello.i
[armlinux@lqm program]$ cat hello.i | less
# 1 "hello.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "hello.c"
# 1 "/usr/include/stdio.h" 1 3
# 28 "/usr/include/stdio.h" 3
# 1 "/usr/include/features.h" 1 3
# 291 "/usr/include/features.h" 3
# 1 "/usr/include/sys/cdefs.h" 1 3
# 292 "/usr/include/features.h" 2 3
# 314 "/usr/include/features.h" 3
# 1 "/usr/include/gnu/stubs.h" 1 3
# 315 "/usr/include/features.h" 2 3
# 29 "/usr/include/stdio.h" 2 3
...
extern void funlockfile (FILE *__stream) ;
# 679 "/usr/include/stdio.h" 3
# 2 "hello.c" 2
int main()
{
}
[armlinux@lqm program]$ gcc -S hello.i -o hello.s
[armlinux@lqm program]$ cat hello.s
.LC0:
.globl main
main:
.L2:
.L5:
.L3:
.Lfe1:
[armlinux@lqm program]$ gcc -c hello.s -o hello.o
[armlinux@lqm program]$ gcc hello.o -o hello1
[armlinux@lqm program]$ ls -l hello1
-rwxrwxr-x
1 armlinux armlinux
11582
8月 28 17:42 hello1
[armlinux@lqm program]$ file hello1
hello1: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), not sd
[armlinux@lqm program]$ gcc -static hello.o -o hello2
[armlinux@lqm program]$ ls -l hello2
-rwxrwxr-x
1 armlinux armlinux
423442
8月 28 17:43 hello2
[armlinux@lqm program]$ file hello2
hello2: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, statically linked, not stripped
[armlinux@lqm program]$ ./hello1
Hello World 1 times!
Hello World 2 times!
Hello World 3 times!
Hello World 4 times!
Hello World 5 times!
Hello World 6 times!
Hello World 7 times!
Hello World 8 times!
[armlinux@lqm program]$ ./hello2
Hello World 1 times!
Hello World 2 times!
Hello World 3 times!
Hello World 4 times!
Hello World 5 times!
Hello World 6 times!
Hello World 7 times!
Hello World 8 times!