<div dir="ltr">Just looked online and stdlibc++ has this at the top the mutex header:<div><br></div><div><a href="https://gcc.gnu.org/onlinedocs/gcc-4.9.3/libstdc++/api/a01070_source.html">https://gcc.gnu.org/onlinedocs/gcc-4.9.3/libstdc++/api/a01070_source.html</a><br><div><br></div><div><div class="" style="font-stretch:normal;font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px;color:rgb(0,0,0)">#if __cplusplus < 201103L</div><div class="" style="font-stretch:normal;font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px;color:rgb(0,0,0)"><a name="l00035" style="color:rgb(61,87,140)"></a># include <bits/c++0x_warning.h></div><div class="" style="font-stretch:normal;font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px;color:rgb(0,0,0)"><a name="l00036" style="color:rgb(61,87,140)"></a>#else</div></div><div><br></div><div>Shouldn't we perform the same sort of check?</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 1, 2016 at 8:57 AM, don hinton <span dir="ltr"><<a href="mailto:hintonda@gmail.com" target="_blank">hintonda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">That's a good point.  Since mutex is a new c++11 feature, why is it injected into the std namespace when not compiling with c++11.  I looked at the mutex header, and it doesn't test current value of __cplusplus.  <div><br></div><div>Should it?</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 29, 2016 at 3:07 PM, Jim Porter via cfe-users <span dir="ltr"><<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 2/29/2016 12:15 PM, Brian Cole via cfe-users wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Was hoping for something that would be C++03 compatible as well since we<br>
still have C++03 compilers to target as well.<br>
</blockquote>
<br></span>
If you're #including <mutex>, haven't you locked yourself into C++11 (or better) anyway? In that case, you should use curly braces for your initializer (or at least stop saying `using namespace std;`).<br>
<br>
For existing code where `mutex` is a global variable, you'll be fine. If you add<span><br>
<br>
  #include <mutex><br>
  using namespace std;<br>
<br></span>
to existing code, you'll get a compiler error because the name `mutex` is now ambiguous.<br>
<br>
If you wanted to warn about this in *all* cases, you'd need an additional warning to detect function declarations in local scope, since that's what C++ would treat this as. Clang doesn't have such a warning, but perhaps you could convince someone to add it.<br>
<br>
- Jim<div><div><br>
<br>
<br>
_______________________________________________<br>
cfe-users mailing list<br>
<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>