<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
The assert is to force the person porting the header to a new system to
check to see what is appropriate for that system. I believe os specific
code ought to be proactively written, not defaulted, even if the
default is to leave it undefined.<br>
<br>
Making it proactive means the maintainer looking at it knows that yes,
it is undefined for system X, rather than being overlooked.<br>
<br>
And I agree that having a default be a particular value is just a land
mine waiting to blow the next person's foot off.<br>
<br>
<br>
Sean Kelly wrote:
<blockquote
 cite="mid:A065B05E-E7B3-40A2-953B-D87E2453533D@invisibleduck.org"
 type="cite">
  <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 moz-do-not-send="true"
 href="mailto:walter@digitalmars.com">walter@digitalmars.com</a>>
wrote:<br>
  <br>
  </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 moz-do-not-send="true"
 href="mailto:D-runtime@puremagic.com">D-runtime@puremagic.com</a></span><br>
    <span><a moz-do-not-send="true"
 href="http://lists.puremagic.com/mailman/listinfo/d-runtime">http://lists.puremagic.com/mailman/listinfo/d-runtime</a></span><br>
    </div>
  </blockquote>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
D-runtime mailing list
<a class="moz-txt-link-abbreviated" href="mailto:D-runtime@puremagic.com">D-runtime@puremagic.com</a>
<a class="moz-txt-link-freetext" href="http://lists.puremagic.com/mailman/listinfo/d-runtime">http://lists.puremagic.com/mailman/listinfo/d-runtime</a>
  </pre>
</blockquote>
</body>
</html>