BYTE, WORD and DWORD macros definition

前端 未结 2 1463
小蘑菇
小蘑菇 2021-01-12 17:52

I am trying to understand, what would be the best way to define BYTE, WORD and DWORD macros, which are mentioned in answers of this qu

相关标签:
2条回答
  • 2021-01-12 18:19

    You have it defined at: https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx, and that is already defined in Windows Data Type headers for WinAPI:

    typedef unsigned short WORD;
    typedef unsigned char BYTE;
    typedef unsigned long DWORD;
    

    and it is a type, and not a macro.

    0 讨论(0)
  • 2021-01-12 18:21

    This is a portable solution:

    #include <stdint.h>
    
    typedef uint32_t DWORD;   // DWORD = unsigned 32 bit value
    typedef uint16_t WORD;    // WORD = unsigned 16 bit value
    typedef uint8_t BYTE;     // BYTE = unsigned 8 bit value
    
    0 讨论(0)
提交回复
热议问题