compiling on windows and linux

前端 未结 4 1810
闹比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:05

    typedef would be better in this instance because #define is just a generic mechanism but typedef is for defining types which is what you are doing.

    I would say put your code:

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

    into a new header file (with #define guards/#pragma once), then include that from the header or source files as necessary.

提交回复
热议问题