0

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?

e271p314
  • 3,841
  • 7
  • 36
  • 61
  • Possible duplicates: http://stackoverflow.com/questions/3378560/how-to-disable-gcc-warnings-for-a-few-lines-of-code , http://stackoverflow.com/questions/1079997/disable-specific-warnings-in-gcc , http://stackoverflow.com/questions/965093/selectively-disable-gcc-warnings-for-only-part-of-a-translation-unit – JBentley Jan 27 '14 at 12:29
  • 1
    if you compile with gcc then use -isystem – Ezra Jan 27 '14 at 12:31
  • @ezra That isn't quite what he's asking - he wants to be able to disable warnings for a specific file **and** at a specific inclusion point of his code. -isystem will disable warnings for a specific file, at all points of inclusion – JBentley Jan 27 '14 at 12:35

1 Answers1

1

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.

David Hammen
  • 32,454
  • 9
  • 60
  • 108
  • Sounds good, I'll give it a try and accept your answer if it works. It's a pity though I need to change the code, I was hoping to find an option to `gcc`, but I guess this option doesn't exist since it needs to many parameters. – e271p314 Jan 27 '14 at 12:41