<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 26, 2015 at 2:31 PM, Geoffrey Garen <span dir="ltr">&lt;<a href="mailto:ggaren@apple.com" target="_blank">ggaren@apple.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span class=""><div><blockquote type="cite"><div>And I do agree that it can be inconvenient to deal with these warnings in heavily #ifdef’d code. I think there are some good strategies for avoiding that, and I’d like to talk about specific irritating cases so I can propose the strategy I’d push for. Generally the strategy is to push more configuration specifics to the edges rather than spreading them through multiple functions.<br></div></blockquote><div><br></div></div></span>A few irritating cases for me:<div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>(1)</div><div><br></div><div><div>static inline void validate(const Range&amp; range)</div></div><div><div>{</div></div><div><div>    UNUSED(range);</div></div><div><div>IF_DEBUG(</div></div><div><div>    BeginTag* beginTag = LargeChunk::beginTag(range.begin());</div></div><div><div>    EndTag* endTag = LargeChunk::endTag(range.begin(), range.size());</div></div><div><div><br></div></div><div><div>    BASSERT(!beginTag-&gt;isEnd());</div></div><div><div>    BASSERT(range.size() &gt;= largeMin);</div></div><div><div>    BASSERT(beginTag-&gt;size() == range.size());</div></div><div><div><br></div></div><div><div>    BASSERT(beginTag-&gt;size() == endTag-&gt;size());</div></div><div><div>    BASSERT(beginTag-&gt;isFree() == endTag-&gt;isFree());</div></div><div><div>    BASSERT(beginTag-&gt;hasPhysicalPages() == endTag-&gt;hasPhysicalPages());</div></div><div><div>    BASSERT(static_cast&lt;BoundaryTag*&gt;(endTag) == static_cast&lt;BoundaryTag*&gt;(beginTag) || endTag-&gt;isEnd());</div></div><div><div>);</div></div><div><div>}</div></div><div><br></div><div>(2)</div><div><br></div><div><div>inline void vmValidate(size_t vmSize)</div></div><div><div>{</div></div><div><div>    // We use getpagesize() here instead of vmPageSize because vmPageSize is</div></div><div><div>    // allowed to be larger than the OS&#39;s true page size.</div></div><div><div><br></div></div><div><div>    UNUSED(vmSize);</div></div><div><div>    BASSERT(vmSize);</div></div><div><div>    BASSERT(vmSize == roundUpToMultipleOf(static_cast&lt;size_t&gt;(getpagesize()), vmSize));</div></div><div><div>}</div></div><div><div><br></div></div><div>(3)</div><div><br></div><div><div>inline void vmValidate(void* p, size_t vmSize)</div></div><div><div>{</div></div><div><div>    // We use getpagesize() here instead of vmPageSize because vmPageSize is</div></div><div><div>    // allowed to be larger than the OS&#39;s true page size.</div></div><div><div><br></div></div><div><div>    vmValidate(vmSize);</div></div><div><div>    </div></div><div><div>    UNUSED(p);</div></div><div><div>    BASSERT(p);</div></div><div><div>    BASSERT(p == mask(p, ~(getpagesize() - 1)));</div></div><div><div>}</div></div></blockquote><div><div><br></div></div><div>The common theme in these cases is that I wanted to write a helper function to do some ASSERTs which compiled to nothing in a release build. Compiling the function to nothing made its parameters look like errors.</div></div></blockquote><div><br></div><div>[snip]</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div>Geoff</div></div></blockquote><div><br></div><div>Are there reasons any or all of these shouldn&#39;t be written as macros?</div><div><br></div><div>Alfonso<br></div><div><br></div></div></div></div>