[D-runtime] How not to write OS specific code

Jonathan M Davis jmdavisProg at gmx.com
Tue Feb 1 18:42:23 PST 2011


On Tuesday 01 February 2011 18:28:07 Sean Kelly wrote:
> 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.

Well, if the static assert(0) is there in the false, then when you try and 
compile it on a new OS, you know that that's something that needs to be dealt  
with. If the solution on that OS is to just not have anything defined for that 
block, then you add an else version block for that OS with nothing in it, and if 
it is supposed to have those definitions, then you define them appropriately. 
Regardless, it won't get missed that way. If you don't have that else block, 
then you're likely to miss it when trying to get druntime to compile and run on 
a new OS unless not having it results in something not compiling.

- Jonathan M Davis


More information about the D-runtime mailing list