title: Suppressing warning about #pragma pack in included file
body: <p>I'm building some code with clang. Here's a cut-down version of what I'm doing. (Please bear in mind that during the cutting-down process, I've cut out every irrelevant detail I can, including anything that might make it obvious why I might actually want to do this.)</p>
  
  <p>push.h:</p>
  
  <pre><code>#pragma GCC diagnostic push
  #pragma GCC diagnostic ignored "-Wpragma-pack"
  #pragma pack(push)
  #pragma pack(1)
  </code></pre>
  
  <p>pop.h:</p>
  
  <pre><code>#pragma pack(pop)
  #pragma GCC diagnostic pop
  </code></pre>
  
  <p>main.c:</p>
  
  <pre><code>#include "push.h"
  struct Fred {char x;};
  #include "pop.h"
  </code></pre>
  
  <p>Compile it like this:</p>
  
  <pre><code>clang -Wall -pedantic -c main.c
  </code></pre>
  
  <p>Doing this, I get a warning:</p>
  
  <pre><code>tmbp ~/tmp/pushpack % clang -Wall -pedantic -c main.c
  main.c:3:10: warning: the current #pragma pack aligment value is modified in the included file [-Wpragma-pack]
  #include "pop.h"
           ^
  note: previous '#pragma pack' directive that modifies alignment is here
  1 warning generated.
  tmbp ~/tmp/pushpack %
  </code></pre>
  
  <p>How can I suppress this warning in this case? I'd like to do this by adding something to pop.h, if possible.</p>
  
  <p>I don't really want to suppress the warning globally, because it seems like it might be kind of useful in the long run (even if not when I'm including push.h and pop.h).</p>
  
  <p>I don't want to add additional junk to every include of pop.h, because in my non-cut-down actual program, because there's tons of them.</p>
  
  <p>I don't want to have just a naked <code>#pragma pack(pop)</code> instead, because I'd prefer things to be symmetrical.</p>
  
  <p>I don't want to make them symmetrical by inlining the contents of push.h, because in practice there's a bit more to it than is shown here.</p>
  
  <p>What, if any, are my options?</p>
  
  <p>Clang version: (this is the one that comes with Xcode 10 - don't think this warning was there in Xcode 9)</p>
  
  <pre><code>tmbp ~/tmp/pushpack % clang --version
  Apple LLVM version 10.0.0 (clang-1000.11.45.2)
  Target: x86_64-apple-darwin17.7.0
  Thread model: posix
  InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
  </code></pre>