CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: #defines

  1. #1
    Join Date
    Oct 2001
    Posts
    745

    #defines

    Helo,
    Iam trying to port my application developed under windows to Linux.

    I want to put some codes between #define's.
    For Eg:-

    Iam giving "WIN32" for windows.What is the equivalent for Linux

    Thanks in advance

  2. #2
    Join Date
    Jun 2002
    Posts
    1,417
    _WIN32 is Microsoft-specific symbol that is defined by the VC6 (and earlier) IDE and used in many of the VC6 header files. Its not a standard C/C++ definition. In Linux you can define anything you want. What I normally do is something like this:

    In a header file that is included in all other *.cpp files:
    #define _LINUX

    Then in the *.cpp file:

    #if defined(_WIN32)
    // MS Windows stuff
    #else if defined(_LINUX)
    // linux stuff
    #else
    // some other operating system
    #endif

  3. #3
    Join Date
    Apr 2000
    Location
    Frederick, Maryland
    Posts
    507
    I wrote this when developing code for both Linux and Windows

    Code:
    #ifdef __linux__
    
    // Linux Code
    
    #endif
    And if __linux__ is not define on any plateform then define it myself.

    Hope it helps.
    Last edited by Zeeshan; August 1st, 2002 at 05:42 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured