开发者

With GCC, can I disable -Wframe-larger-than on a per-function basis?

Using GCC, is it possible to specify a set of functions that are exempt from -Wfr开发者_运维百科ame-larger-than? (For example, main.)


GCC supplies you with pragmas for this purpose:

http://gcc.gnu.org/onlinedocs/gcc-4.5.2/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas

Currently it won't do exactly what you want, since it seems to do it on a file by file basis, but in the next version of gcc (4.6), it appears as though it is context aware:

http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas


This is a bit old, but I came across it looking for the same answer, so I thought I'd post my solution (found by trial and error):

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wframe-larger-than="

void func() 
{ int x[2000] = {}; printf("%d",x[1]); }    

#pragma GCC diagnostic pop

seems to work. For some reason, trying to use diagnostic warning did not work. It does not seem possible to change the stack size that generates the warning. Also, you need the = at the end. Maybe the next guy will find this and save themselves some time :). This is 4.6.2 (on an ARM cross compiler).

John


You can use the GCC diagnostic pragma.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜