Thread: windows a definition?

  1. #1
    Algorithm engineer
    Join Date
    Jun 2006
    Posts
    286

    Question windows a definition?

    How can you tell in your preprocessing code if the program is being compiled in windows or in linux or in any other system if you would like to know that?

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Yes, there are several #defines that you can check for with #ifdef to see what system is running and define the appropriate code depending on that. I don't know exact examples, right now, though.

    ...how about this:
    Code:
    #include <stdio.h>
    #ifdef WIN32
       #define str "This is 32bit Windows"
    #else
       #define str "This is some other OS"
    #endif
    
    int main() {
        printf("%s",str);
    }
    Last edited by SlyMaelstrom; 07-21-2006 at 06:35 PM.
    Sent from my iPadŽ

  3. #3
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Windows 98/2000 programming in Windows XP
    By Bill83 in forum Windows Programming
    Replies: 3
    Last Post: 07-22-2005, 02:16 PM
  2. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 05:48 PM
  3. dual boot Win XP, win 2000
    By Micko in forum Tech Board
    Replies: 6
    Last Post: 05-30-2005, 02:55 PM
  4. SDL and Windows
    By nickname_changed in forum Windows Programming
    Replies: 14
    Last Post: 10-24-2003, 12:19 AM
  5. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM