Compartilhar via


Conditional Compilation

4/19/2010

Depending on which platform you are targeting at compile time, you can use conditional compilation to include or exclude certain portions of code, as shown in the following code example.

Code Example

        #ifdef WIN32_PLATFORM_PSPC
    // Code for either Windows Mobile Classic or Windows Mobile Professional.

#if (WIN32_PLATFORM_PSPC = 400)
    // Code for Windows Mobile 2003.
    LoadString(g_hInst, IDS_PPC2003, szBuf, MAX_LOADSTRING);

#elif (WIN32_PLATFORM_PSPC = 310)
    // Code for Pocket PC 2002.
    LoadString(g_hInst, IDS_PPC2002, szBuf, MAX_LOADSTRING);

#endif

#endif // WIN32_PLATFORM_PSPC

Remarks

Using a conditional compilation approach, as opposed to runtime platform and version checking, results in a separate executable file for each targeted platform.

See Also

Reference

Runtime Platform and Version Checking

Concepts

Writing Code for Multiple Devices and Versions
How to Implement Runtime Platform and Version Checking