Werror ignores certain files

I am wondering if it is possible to have werror in gcc / g ++ to exclude certain files (those that I don’t have to modify the source code) so that I can continue to use werror in an unlimited state.

+3
source share
3 answers

Use the pragma directives with the newer version of gcc (4.2, I think) to disable -Werror for some headers before they are included.

You might want to accept the answers to your previous questions.

+3
source

, , -Werror, - -Werror.

0

@ , ...

-Werror #pragma GCC diagnostics warning "-W<kind>". :

#pragma GCC diagnostic push
# pragma GCC diagnostic warning "-Wreturn-type"
# pragma GCC diagnostic warning "-Wmissing-braces"
# include "legacy-crap.h"
#pragma GCC diagnostic pop

gcc /:

warning-test.c:11:1: warning: return type defaults toint[-Wreturn-type]

warning-test.c:11:1: error: return type defaults toint[-Wreturn-type]

This can be used to accurately select the exact diagnosis, which should be considered a warning instead of an error during processing by a third party that you cannot change. I don’t know a short hand to turn off all warnings ( "-Wall"it will not have the desired effect for the above #pragma), but I think it’s also good to be explicit here.

0
source

Source: https://habr.com/ru/post/1756656/


All Articles