5
votes

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 ?

1

1 Answers

7
votes

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="