Chinaunix首页 | 论坛 | 博客
  • 博客访问: 217057
  • 博文数量: 20
  • 博客积分: 2016
  • 博客等级: 大尉
  • 技术积分: 660
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-16 00:15
文章分类

全部博文(20)

文章存档

2010年(1)

2008年(19)

我的朋友

分类: LINUX

2008-10-15 14:52:07

A special file, preprocessed file, is usually useful for our development. Supposed that when we are building a large project containing some header files with same name in different directories, an error occurs when some file is compiling, indicating that some symbol is not defined. After long time checking source code, we could not find out the root cause since the corresponding header file has been included. In this case, the preprocessed file could help us locate the root cause.

First of all, let's explain how to generate the preprocessed file. There are two methods to generate the preprocessed files:

1) Use option -E

gcc -c hello.c -E -o hello.i

2) Use option -save-temps

gcc -c hello.c -o hello.o -save-temps

These two methods will all generate the preprocessed hello.i, which is generated by the preprocessor of gnu toolchains.

Then you can open the file, and find whehter the file contains the missed symbol. Obviously, maybe the wrong header file with same name in other folder is included in your source code.

Above example is just a simple usage of the preprocessed file. Since this file contains all variables and functions defined in the included files, it will provide all what you want to see in the target file.
阅读(753) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~