编译先前预处理的文件更改输出 [英] Compiling previously preprocessed file changes output

查看:212
本文介绍了编译先前预处理的文件更改输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个源文件,我使用选项 -E -P 2用于基于vxWorks的嵌入式平台)。所有其他选项与编译文件时相同。这些选项是:

I have a source file which I preprocess using the options -E and -P (using GCC 4.1.2 for a vxWorks-based embedded platform). All other options are the same as when I compile the file. These options are:

-Wall  
-march=pentium 
-nostdinc 
-O0 
-fno-builtin 
-fno-defer-pop
-g  
-c
-o

以及所有包含路径。现在当我编译这个预处理文件时,生成的对象文件比我直接编译原始的小得多(约30%)。然后,当我链接程序时,链接器提示丢失符号(所有在用户代码中),这在使用原始源文件时也不会发生。为什么有区别?

as well as all include-paths. Now when I compile this preprocessed file, the resulting object-file is much smaller (about 30%) than when I compile the original directly. And when I then link the program, the linker complains about missing symbols (all in user-code), which again does not happen when using the original source-file. Why is there a difference? Is there any way to make this work?

推荐答案

在编译预处理输出时,尝试传递 fpreprocessed 选项来告诉GCC不要再次预处理。

When compiling the preprocessed output, try passing the -fpreprocessed option to tell GCC not to preprocess again.

我可以想到的唯一的区别是宏,导致扩展到一个标识符已经扩展的宏名称 - 预处理器在该点停止扩展,但是如果再次运行预处理器,标识符将再次扩展。我希望任何这种情况可能会导致编译器错误,但谁知道?

The only difference I can think of is macros that result in expanding to an identifier that's a macro name that has already been expanded - the preprocessor stops expansion at that point, but if you ran the preprocessor again, the identifier would be expanded again. I would have expected any instances of this to probably cause a compiler error, but who knows?

这篇关于编译先前预处理的文件更改输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆