I am trying to compile a project that imports this BiTStream file.
GCC outputs the following error:
warning: stack usage might be unbounded [-Wstack-usage=]
Indeed, in the compilation command line (generated via CMake) I have:
-Wstack-usage=2048
I want to keep this warning for the rest of the project but disable it for this specific file.
I have checked GCC Warnings options and GCC diagnostic pragmas and tried:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-enum"
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wswitch-default"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wstack-usage"
#include <bitstream/mpeg/psi/descs_print.h>
#pragma GCC diagnostic pop
But GCC still complains:
warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
#pragma GCC diagnostic warning "-Wstack-usage"
Note that the other warnings are correctly disabled.
Is there a specific synatx for Wstack-usage
?
The warning message for each controllable warning includes the option that controls the warning. That option can then be used with -Werror= and -Wno-error= as described above. (Printing of the option in the warning message can be disabled using the -fno-diagnostics-show-option flag.)
You can make all warnings being treated as such using -Wno-error. You can make specific warnings being treated as such by using -Wno-error=<warning name> where <warning name> is the name of the warning you don't want treated as an error. If you want to entirely disable all warnings, use -w (not recommended).
Maybe you can look for CFLAGS options in Makefile and remove the -Werror flag. The Werror flag will make all warnings into errors.
You can use the -Werror compiler flag to turn all or some warnings into errors. Show activity on this post. You can use -fdiagnostics-show-option to see the -W option that applies to a particular warning.
The clue is in the error message:
warning: stack usage might be unbounded [-Wstack-usage=]
Thus, the #pragma you need to use is:
#pragma GCC diagnostic ignored "-Wstack-usage="
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With