title: How to require a semicolon after a macro
body: <p>So I am writing a library that has to build with <code>-pedantic -ansi -std=c++98 -Werror</code> and <code>-Weverything</code> for clang and <code>-Wall -Wextra</code> for gcc and I have this macro <code>TESTSUITE(X)</code> which is intended to be used in global scope like this:</p>
  
  <pre><code>TESTSUITE(current testsuite);
  </code></pre>
  
  <p>and what it does is call a function (on program startup by initializing a dummy var) with the string:</p>
  
  <pre><code>#define TESTSUITE(name) \
  static int ANONYMOUS_VARIABLE(SOME_PREFIX) = setTestSuiteName(#name)
  </code></pre>
  
  <p>The problem is that this generates a warning under clang for <code>-Wglobal-constructors</code>.</p>
  
  <p>If I surround it with <code>_Pragma</code> like this:</p>
  
  <pre><code>#define TESTSUITE(name)                                              \
  _Pragma("clang diagnostic push");                                    \
  _Pragma("clang diagnostic ignored \"-Wglobal-constructors\"");       \
  static int ANONYMOUS_VARIABLE(SOME_PREFIX) = setTestSuiteName(#name) \
  _Pragma("clang diagnostic pop")
  </code></pre>
  
  <p>the semicolon after using the macro will not be required for compilation (and when it is missing <code>-pedantic</code> gives an error).</p>
  
  <p>If I add this at the end of the macro</p>
  
  <pre><code>static int ANONYMOUS_VARIABLE(SOME_PREFIX) = 5
  </code></pre>
  
  <p>the semicolon will be required but I will get a warning for an unused variable which I cannot silence (because if I surround it with <code>_Pragma</code> statements I will be back to square 1 not requiring a semicolon).</p>
  
  <p>So does anyone have an idea how I can require the semicolon and also have 0 warnings?</p>