-
Book Overview & Buying
-
Table Of Contents
D Cookbook
By :
Different platforms often need specialized code. D provides the version statement for this case, which is similar to but cleaner than C's #ifdef directives. In addition to platforms, special code may be needed when building customized versions of an application for a specific client or other special case. While version can do that job, it isn't ideal. So, we'll use another technique: configuration modules.
Writing platform-specific code and writing client-specific code is best done with two different techniques.
Perform the following steps:
Write version statements for all supported platforms.
Write else static assert(0, "Unsupported platform"); at the end of the version list.
Don't try to mix partial declarations for different platforms together, it will be more trouble than it is worth.
The code is as follows:
version(Windows)
void writeToFile(HANDLE file, in void[] data) {
if(...
Change the font size
Change margin width
Change background colour