使用GCC,是否可以指定一组函数,免受-Wframe-larger-than的影响?(例如,main函数)
GCC提供了用于此目的的编译指示:
http://gcc.gnu.org/onlinedocs/gcc-4.5.2/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas
目前它不能完全按您的要求执行,因为它似乎是基于文件的,但在下一个版本的gcc (4.6) 中,它似乎是上下文感知的:
http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas
这篇文章有点旧,但是我在寻找同样的答案时发现了它,于是我想发布我的解决方案(通过试错找到):
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wframe-larger-than="
void func()
{ int x[2000] = {}; printf("%d",x[1]); }
#pragma GCC diagnostic pop
#pragma GCC diagnostic ignored "-Wframe-larger-than="
)。不过现在我更想要GCC 4.6了。 - user79758