Domanda

I'm using boost for a project I'm working on. Some of my files include one or more of the boost headers which in turn include other boost headers, which in one of them there is a variable which is set but not used. This prints an ugly warning to my screen which makes it hard to read the output especially when I have a real compilation error but I need to look carefully in the output to distinguish which text belongs to the set but not used warning and which is related to the real compilation error I want to solve.

I don't want to disable this warning to the entire project or even to some specific files in my project because I want to see this warning if I set a variable in my code but I don't use it. I want only the warning which happens in a specific line and specific file to be ignored.

Is there an option for gcc to suppress specific warnings in specific location in the code?

È stato utile?

Soluzione

gcc offers diagnostic pragmas. See http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html.

Use these in your code before and after you #include those third party headers. Do not modify those the third party code to suit your compilation flags.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top