是否有一个gcc宏用于确定未消除帧指针? [英] Is there a gcc macro for determining that frame pointers are not eliminated?
问题描述
使用-fomit-frame-pointer(对于各种-O设置自动)时,执行回溯是有问题的.我想知道是否有一种方法可以在编译时确定使用此开关编译代码吗?在这种情况下,我可以在不明智的情况下输入#ifndef来防止回溯.
When -fomit-frame-pointer is used (automatic for various -O settings), performing a backtrace is problematic. I am wondering if there is a way of determining at compile time that the code is compiled with this switch? In that case, I could put in an #ifndef to guard against backtracing when ill-advised.
此-fomit-frame-pointer开关打开时,是否设置了宏?
Is any macro set when this -fomit-frame-pointer switch is on?
谢谢
SetJmp
推荐答案
我刚刚尝试过:
gcc -E -fomit-frame-pointer -Wp,-dM foo.c > fpo.out
gcc -E -Wp,-dM foo.c > no-fpo.out
diff no-fpo.out fpo.out
其中foo.c是一个简单的"Hello World"程序,没有任何结果.这意味着无论是否使用-fomit-frame-pointer
,所有预处理器宏都相同.因此,我认为您的问题的答案是否".
where foo.c is a simple "Hello World" program, and got no results. This means all of the preprocessor macros were identical, whether -fomit-frame-pointer
was used or not. So I think the answer to your question is "no".
可能最好的办法是在使用-fomit-frame-pointer
时修改Makefile(或任何构建过程使用的东西)以定义您的 own 宏(例如-DNO_FRAME_POINTERS
等).
Probably the best you can do is modify your Makefile (or whatever your build process uses) to define your own macro (e.g. -DNO_FRAME_POINTERS
, or something) when using -fomit-frame-pointer
.
这篇关于是否有一个gcc宏用于确定未消除帧指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!