<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi Sanitizer Runtime Developers,</div><div class=""><br class=""></div>We recently ran into a problem building clang because some of the definitions in sanitizer_common conflicted with system definitions and later another system header was trying to use the system definition:<div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Menlo" class="">.../usr/include/libkern/OSAtomicDeprecated.h:756:17: error: reference to 'memory_order_relaxed' is ambiguous</font></div><div class=""><font face="Menlo" class="">__theAmount, memory_order_relaxed) + __theAmount);</font></div><div class=""><font face="Menlo" class="">^</font></div><div class=""><font face="Menlo" class="">.../usr/bin/../include/c++/v1/atomic:548:5: note: candidate found by name lookup is 'std::__1::memory_order::memory_order_relaxed'</font></div><div class=""><font face="Menlo" class="">memory_order_relaxed, memory_order_consume, memory_order_acquire,</font></div><div class=""><font face="Menlo" class="">^</font></div><div class=""><font face="Menlo" class="">../src/projects/compiler-rt/lib/tsan/../sanitizer_common/sanitizer_atomic.h:22:3: note: candidate found by name lookup is '__sanitizer::memory_order::memory_order_relaxed'</font></div><div class=""><font face="Menlo" class="">memory_order_relaxed = 1 << 0,</font></div><div class=""><font face="Menlo" class="">^</font></div></blockquote><div class=""><br class=""></div><div class="">The problem is due to the combination of the following: </div><div class=""> 1. The runtime includes the system headers after the project headers (as per LLVM coding guidelines).</div><div class=""> 2. <span style="font-family: Menlo;" class="">lib/sanitizer_common/sanitizer_internal_defs.h</span> pollutes the namespace of everything defined after it, which is all/most of the sanitizer .h and .cc files and the included system headers with:</div><div class=""><font face="Menlo" class="">    using namespace __sanitizer;  // NOLINT</font></div><div class=""> 3. These are the definitions that conflict in this particular case, but this problem could reoccur in the future with other symbols as well:</div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Menlo" class=""><div class="">enum memory_order {</div></font></div><div class=""><font face="Menlo" class=""><div class="">  memory_order_relaxed = 1 << 0,</div></font></div><div class=""><font face="Menlo" class=""><div class="">  memory_order_consume = 1 << 1,</div></font></div><div class=""><font face="Menlo" class=""><div class="">  memory_order_acquire = 1 << 2,</div></font></div><div class=""><font face="Menlo" class=""><div class="">  memory_order_release = 1 << 3,</div></font></div><div class=""><font face="Menlo" class=""><div class="">  memory_order_acq_rel = 1 << 4,</div></font></div><div class=""><font face="Menlo" class=""><div class="">  memory_order_seq_cst = 1 << 5</div></font></div><div class=""><font face="Menlo" class=""><div class="">};</div></font></div></blockquote><div class=""><br class=""></div><div class="">We currently have a workaround (in the system header) that makes this non-blocking, but it would be good to cleanly address this problem. Removing the "using namespace" from the header seems like the cleanest solution. WDYT?</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Anna.</div></body></html>