<html><body bgcolor="#FFFFFF"><div>I don't know that the static assert is appropriate, since that stuff is optional, and the convention in the Posix headers is not to have an assert for undefined blocks, but it's no big deal to me either way. The 'else' clause was clearly wrong however.<br><br>Sent from my iPhone</div><div><br>On Feb 1, 2011, at 10:55 AM, Walter Bright <<a href="mailto:walter@digitalmars.com">walter@digitalmars.com</a>> wrote:<br><br></div><div></div><blockquote type="cite"><div>

Found this today in src/core/sys/posix/time.d:<br>
<br>
<tt>version( linux )<br>
{<br>
    enum CLOCK_MONOTONIC        = 1;<br>
    enum CLOCK_MONOTONIC_RAW    = 4; // non-standard<br>
    enum CLOCK_MONOTONIC_COARSE = 6; // non-standard<br>
}<br>
else<br>
{<br>
    enum CLOCK_MONOTONIC        = 4;<br>
}</tt><br>
<br>
This is <font color="#cc0000"><b>WRONG WRONG WRONG</b></font>.<br>
<br>
1. it's wrong for OSX, which does not even define CLOCK_MONOTONIC<br>
2. there's no guarantee that on "other" operating systems
CLOCK_MONOTONIC will be defined, or if it is, that it will be 4.<br>
3. you only find out there's a problem when something mysterious
happens.<br>
4. cut & pasting declarations from one operating system to another
without checking is akin to dropping an anvil on the head of the
hapless developer who can't figure out why there are mysterious
failures on that other system. The developer then has to go back and
hand-check every last one of those declarations.<br>
<br>
This is <b><font color="#cc0000">not</font></b> acceptable practice.
Declarations for an OS should never be inserted or enabled until they
are checked.<br>
<br>
The corrected version is:<br>
<br>
<tt>version( linux )<br>
{<br>
    enum CLOCK_MONOTONIC        = 1;<br>
    enum CLOCK_MONOTONIC_RAW    = 4; // non-standard<br>
    enum CLOCK_MONOTONIC_COARSE = 6; // non-standard<br>
}<br>
else version (FreeBSD)<br>
{   // time.h<br>
    enum CLOCK_MONOTONIC         = 4;<br>
    enum CLOCK_MONOTONIC_PRECISE = 11;<br>
    enum CLOCK_MONOTONIC_FAST    = 12;<br>
}<br>
else version (OSX)<br>
{<br>
    // No CLOCK_MONOTONIC defined<br>
}<br>
else<br>
{<br>
    static assert(0);<br>
}</tt><br>
<br>
Note that the assert will trip when a new OS is tried, thus pointing
the developer at places that need to be checked.<br>


</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>D-runtime mailing list</span><br><span><a href="mailto:D-runtime@puremagic.com">D-runtime@puremagic.com</a></span><br><span><a href="http://lists.puremagic.com/mailman/listinfo/d-runtime">http://lists.puremagic.com/mailman/listinfo/d-runtime</a></span><br></div></blockquote></body></html>