Question on preprocessor directives

Posted by dotnetdev on Stack Overflow See other posts from Stack Overflow or by dotnetdev
Published on 2010-06-07T10:06:56Z Indexed on 2010/06/07 10:12 UTC
Read the original article Hit count: 223

Filed under:

If I use proprocessor directives to define which code an OS will run, like so:

     #if winXP // Compiling for Windows XP
    platformName = "Microsoft Windows XP";
    #elif win2000 // Compiling for Windows 2000
    platformName = "Microsoft Windows 2000";
    #elif win7 // Compiling for Windows 7
    platformName = "Microsoft Windows 7";
    #else // Unknown platform specified
    platformName = "Unknown";

How does the system pick up which OS is being used?

This is an example from the book Visual C# 2010 Recipes, where the author says that the platformName variable (declaration ommitted), wil equal the OS above.

Thanks

© Stack Overflow or respective owner

Related posts about c#