SunOS 5.10 sparc C/C++ 初学者之Hello World !

来源:互联网 发布:2016小说改编网络剧 编辑:程序博客网 时间:2024/05/17 06:44

一、CC

1、工作目录/data/aifront/cpl/others/demo01

<<hello.c>>

#include <stdio.h>main() {printf("Hello World !\n");}
执行命令
[/data/aifront/cpl/others/demo01]CC hello.c[/data/aifront/cpl/others/demo01]a.outHello World !

二、CC分解动作

-P 仅通过预处理程序编译源,输出到 .i 文件[/data/aifront/cpl/others/demo01]CC -P hello.c -o tmp.i -S 编译并仅生成汇编代码 (.s)[/data/aifront/cpl/others/demo01]CC -S tmp.i -o tmp.s -c 仅编译 - 生成 .o 文件,禁止链接[/data/aifront/cpl/others/demo01]CC -c tmp.s -o tmp.o链接[/data/aifront/cpl/others/demo01]CC tmp.o -o bin

三、make

<<makefile>>

/data/aifront/cpl/others/demo01/makefile

COMMAND_C=CC -m32 +w -O3 -gCOMMAND_L=CC -m32main:step_1$(COMMAND_L) tmp.o -o binstep_1:$(COMMAND_C) -c hello.c -o tmp.oclean:rm -rf *.o
执行编译命令

[/data/aifront/cpl/others/demo01]makeCC -m32 +w -O3 -g -c hello.c -o tmp.o"hello.c", 第 3 行: 警告: C++ 不支持在函数 main() 中使用隐式的 int.检测到 1 警告.CC -m32 tmp.o -o bin
运行编译好的程序

[/data/aifront/cpl/others/demo01]binHello World !
清理编译时的临时文件

[/data/aifront/cpl/others/demo01]make cleanrm -rf *.o

只编译出tmp.o文件

[/data/aifront/cpl/others/demo01]make step_1CC -m32 +w -O3 -g -c hello.c -o tmp.o"hello.c", 第 3 行: 警告: C++ 不支持在函数 main() 中使用隐式的 int.检测到 1 警告.



原创粉丝点击