Using alerts
This is the GCC specification (verified with gcc 4.9):
Add this to the above function:
#pragma GCC diagnostic error "-Wframe-larger-than="
Which messages lead to errors, for example:
error: the frame size of 272 bytes is larger than 1 bytes [-Werror=frame-larger-than=]
While a bit of a strange way, you can at least do it quickly by editing the file.
Using CFLAGS
You can add -fstack-usage to your CFLAGS, which then writes text files along object files. See: https://gcc.gnu.org/onlinedocs/gnat_ugn/Static-Stack-Usage-Analysis.html Although this works very well, it may be a little awkward depending on your build / configuration - to create one file with another CFLAG, although this of course can be automated. - (thanks to @nos comment)
Note
It seems that most / all natural compiler methods rely on guesswork, which is not 100% accurate after optimization, so this at least gives a definitive answer using a free compiler.
source share