您的位置:首页 > 其它

博客

2016-07-15 16:31 295 查看
hello 博客

我的第一个博客。

1 如何编译源代码
   1. `./do`
   2. 生成可执行文件`./cit`
2 如何使用cit-86
  1. 命令格式`./cit -h`
  2. 编译`./cit ./file/test.c test`
  3. 生成可执行文件`./work/test`
  4. 测试运行`./work/test`
void hanoi(string a, string b, string c, int n);

int main() {
int n;
out << "输入盘子个数:";
in >> n;
hanoi("A", "B", "C", n);
return 0;
}

void hanoi(string a, string b, string c, int n) {
if(n == 0) {
return;
} else {
  hanoi(a, c, b, n - 1);
  out << "Move " + n + ":\t[" + a + " --> " + c + "]\n";
  hanoi(b, a, c, n - 1);
  }
}

3 代码的结构和意思
 -finstrument-functions 添加
   instrument.c: In function ‘void __cyg_profile_func_enter(void*)’:
instrument.c:46:31: error: invalid use of ‘this’ in non-member function
   fprintf(fp, "E%p\n", (int *)this);
this 是关键字。。。。改成this2

编译过程:
开始检测输入文件信息...
正在编译文件/home/lc/mygcc/cit-x86/ss.c。
<run: cd ./compiler
./compiler /home/lc/mygcc/cit-x86/ss.c n n n n n   
cd ..
编译完成!(错误=0 警告=0)
正在汇编文件/home/lc/mygcc/cit-x86/work/ss.s。
正在汇编文件/home/lc/mygcc/cit-x86/work/common.s
*******************************************************************
<run: cd ./ass
./ass /home/lc/mygcc/cit-x86/work/ss n
cd ..
这一步产生了 s.o
>正在汇编文件/home/lc/mygcc/cit-x86/work/common.s。
<run: cd ./ass
./ass /home/lc/mygcc/cit-x86/work/common n
cd ..
这一步应该是产生 common.o
>正在执行链接。
<run: cd ./lit
./lit /home/lc/mygcc/cit-x86/work/ss.o /home/lc/mygcc/cit-x86/work/common.o /home/lc/mygcc/cit-x86/work/ss  n
cd ..
><run: chmod +x /home/lc/mygcc/cit-x86/work/ss>
生成可执行文件/home/lc/mygcc/cit-x86/work/ss。
操作成功!

lc@PC:~/mygcc/cit-x86$ ./work/ss 
hello world!
注意无法在目录外面运行 函数不知道为什么??
现在知道了,他们需要一个work文件夹
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: