compiling on windows and linux

前端 未结 4 1835
闹比i
闹比i 2021-02-20 11:50

I am new to c, and I have some been given some source code that someone else has written that was compiled on windows.

After trying to make in compile on linux I have e

4条回答
  •  花落未央
    2021-02-20 12:04

    You have found the solution yourself:

    #ifdef WIN32
    /* windows stuff */
    #else
    typedef unsigned long DWORD;
    typedef unsigned short WORD;
    typedef unsigned int UNINT32;
    #endif
    

    Put this in a separate header file (typedefs.h) and include it from everywhere. Typedef are always preferred over pre-processor macros.

    My recommendation: Do not use DWORD, WORD or other Win32 types. I usually prefer to use C99 standard types: uint_t, int_t or uint16_t, uint32_t

提交回复
热议问题