September 22, 2005 portability tips | ||||
---|---|---|---|---|
| ||||
Attachments: | While reviewing Phobos for 64bit systems I noticed two very common coding problems. 1) If you use conditional compilation(version/debug/static if), always add a sanity check. ### bad ### version(Windows){ ... } version(linux){ ... } ### god ### version(Windows){ ... }else version(linux){ ... }else{ pragma(msg, "didn't yet adapt ...."); static assert(0); } 2) Reevaluate your use of signed, unsigned integers and their size for iteration purposes - especially as array indexes or pointer offsets. Maybe size_t and ptrdiff_t are better suited than int/long and uint/ulong? Thomas |
Copyright © 1999-2021 by the D Language Foundation