title: How to suppress several warnings but not all of them coming from libraries?
body: <p>Some libraries are buggy and raise a lot of warnings one does not want to get at every compilation because it floods usefull own application warnings and errors.</p>
  
  <p>To suppress one type of warnings or all of them from libraries includes, the solution is <a href="https://stackoverflow.com/questions/1867065/how-to-suppress-gcc-warnings-from-library-headers">here</a> from <em>andrewrjones</em> and recalled here for conveniance (with a different example to make it usefull):</p>
  
  <pre><code>// Crypt++
  #pragma GCC diagnostic push
  #pragma GCC diagnostic ignored "-Wunused-variable"
  #include "aes.h"
  #include "modes.h"
  #include "filters.h"
  #include "base64.h"
  #include "randpool.h"
  #include "sha.h"
  #pragma GCC diagnostic pop
  </code></pre>
  
  <p>As explained by <em>andrewrjones</em>, <code>-Wall</code> can be used to suppress all warnings from the included libraries.</p>
  
  <p>But how can I suppress several warnings only, not all of them?</p>
  
  <p>I have tested including them in the string like here:</p>
  
  <pre><code>#pragma GCC diagnostic ignored "-Wunused-variable -Wunused-function"
  </code></pre>
  
  <p>Leading to the following error:</p>
  
  <pre><code>warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
  </code></pre>
  
  <p>Or in two lines:</p>
  
  <pre><code>#pragma GCC diagnostic ignored "-Wunused-variable"
  #pragma GCC diagnostic ignored "-Wunused-function"
  </code></pre>
  
  <p>But the second one is ignored.</p>
  
  <p>The <a href="https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html" rel="nofollow noreferrer">gcc documentation on these diagnostic pragmas</a> is not helpful. How could I do this please?</p>
  
  <p>EDIT: Here is a MCVE:</p>
  
  <pre><code>#include &lt;string&gt;
  #pragma GCC diagnostic push
  #pragma GCC diagnostic ignored "-Wunused-variable"
  #pragma GCC diagnostic ignored "-Wunused-function"
  //#pragma GCC diagnostic ignored "-Wunused-variable,unused-function" // error
  //#pragma GCC diagnostic ignored "-Wall"     // does not work
  #include "aes.h"
  #include "modes.h"
  #include "filters.h"
  #include "base64.h"
  #include "randpool.h"
  #include "sha.h"
  #pragma GCC diagnostic pop
  
  using namespace std;
  using namespace CryptoPP;
  
  int main() {
    byte k[32];
    byte IV[CryptoPP::AES::BLOCKSIZE];
    CBC_Mode&lt;AES&gt;::Decryption Decryptor(k, sizeof(k), IV);
    string cipherText = "*****************";
    string recoveredText;
    StringSource(cipherText, true, new StreamTransformationFilter(Decryptor, new StringSink(recoveredText)));
  }
  </code></pre>
  
  <p>Build with:</p>
  
  <pre><code>g++ -Wall -I/usr/include/crypto++ -lcrypto++ gdi.cpp
  </code></pre>
  
  <p>It appears that it has used to building ignoring the <code>ignored "-Wunused-function"</code>, <strong>and now it works!</strong></p>
  
  <p>In my real app, it is always ignored. So, at this point, I am using the <a href="https://stackoverflow.com/questions/1867065/how-to-suppress-gcc-warnings-from-library-headers">following solution</a> as a workaround: <code>-isystem/usr/include/crypto++</code> instead of <code>-I/usr/include/crypto++</code> in the compilation options. It suppresses all warnings from crypto++.</p>