title: GCC vs Clang: Meaning of "-pedantic-errors"
body: <p>I'm using Clang v3.7.0 with <a href="https://en.wikipedia.org/wiki/Mingw-w64" rel="nofollow noreferrer">Mingw-w64</a> 5.1.0 and GCC 5.1.0, all 64-bit, on Windows 10. My goal is to use a set of Clang and GCC options that will give me the best chance of detecting potential <a href="https://en.wikipedia.org/wiki/ANSI_C#C89" rel="nofollow noreferrer">C89</a> and <a href="https://en.wikipedia.org/wiki/C%2B%2B#Standardization" rel="nofollow noreferrer">C++98</a> language standards portability issues across many different compilers. For example, for C I have been using the following GCC command line with pretty good success:</p>
  <pre class="lang-none prettyprint-override"><code>gcc -c -x c -std=c89 -pedantic-errors -Wall -Wextra -Wno-comment -Wno-parentheses -Wno-format-zero-length test.c
  </code></pre>
  <p>However, I recently tried it with Clang and got a different result. Here is my sample test code:</p>
  <pre><code>int main(void)
  {
      int length = (int)strlen(&quot;Hello&quot;);
      return 0;
  }
  </code></pre>
  <p>With Clang I get the following error, whereas with GCC I get the same basic thing, but it flags it as a warning instead:</p>
  <pre class="lang-none prettyprint-override"><code>test.c:3:22: error: implicitly declaring library function 'strlen'
  with type 'unsigned long long (const char *)'
      int length = (int)strlen(&quot;Hello&quot;);
  </code></pre>
  <p>If I remove the <em><a href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-pedantic-errors-1" rel="nofollow noreferrer">-pedantic-errors</a></em> option, or just change it to <em><a href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-pedantic-1" rel="nofollow noreferrer">-pedantic</a></em>, Clang then only flags it as a warning, which is what I actually want. However, according to the GCC documentation the <em>-pedantic-errors</em> option causes warnings that are considered language extensions to be flagged as errors, but not using a prototype for a function is not an extension in C89. So, I have three basic questions:</p>
  <ol>
  <li><p>Has Clang changed the meaning of <em>-pedantic-errors</em> from the meaning used by GCC, or am I misinterpreting something?</p>
  </li>
  <li><p>What is the best set of options that will enforce adherence to the selected standard and will issue errors for all non-conforming code?</p>
  </li>
  <li><p>If I continue to use <em>-pedantic-errors</em> with Clang is there a way to get it to issue a warning instead of an error in specific cases? In another posting on this site an answer was given that said to use the following, where foo is the error:</p>
  <pre class="lang-none prettyprint-override"><code>-Wno-error=foo
  </code></pre>
  </li>
  </ol>
  <p>If that is a correct approach, what do I actually use in place of <em>foo</em> for an error like I'm getting since there is no actual error number indicated? I can't believe it actually wants all of the following:</p>
  <pre class="lang-none prettyprint-override"><code>-Wno-error=implicitly declaring library function 'strlen'
  with type 'unsigned long long (const char *)'
  </code></pre>