<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">While audit our code, we found out a strange pattern in one of the LLVM headers and we were wondering if that was expected or if it should be fixed.</div><div class=""><br class=""></div><div class="">Namely the problem looks like this:</div><div class=""><font face="Menlo" style="font-size: 11px;" class="">#ifndef NDEBUG</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class="">  // Define some variable.</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class="">#endif</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""><br class=""></font></div><div class=""><font face="Menlo" style="font-size: 11px;" class="">assert(/*use this variable, i.e., outside of the ifndef NDEBUG scope*/);</font></div><div class=""><br class=""></div><div class="">This happens in <span style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);" class="">include/llvm/IR/ValueHandle.h </span>for the variable <span style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);" class="">Poisoned </span>line 494</div><div class=""><br class=""></div><div class="">This works because when we build LLVM with assert we explicitly disable NDEBUG:</div><div class=""><div class=""><font face="Menlo" style="font-size: 11px;" class="">if( LLVM_ENABLE_ASSERTIONS )</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class="">  […]</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class="">  # On non-Debug builds cmake automatically defines NDEBUG, so we</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class="">  # explicitly undefine it:</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class="">  if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class="">    add_definitions( -UNDEBUG )</font></div></div><div class=""><br class=""></div><div class="">If we use this header in a different project and thus, with potentially different rules for macro definitions, the compiler complains with</div><div class=""><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">error:   use of undeclared identifier ‘Poisoned'</span></font></div></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""><br class=""></font></div><div class="">I think the right thing to do is to fix the code to work without the special way of setting the macros, but I’d like people opinions first.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">-Quentin</div></body></html>