types.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. This software is subject to the license described in the License.txt file
  3. included with this software distribution. You may not use this file except in compliance
  4. with this license.
  5. Copyright (c) Dynastream Innovations Inc. 2012
  6. All rights reserved.
  7. */
  8. #ifndef TYPES_H
  9. #define TYPES_H
  10. #include <windows.h>
  11. //////////////////////////////////////////////////////////////////////////////////
  12. // Public Definitions
  13. //////////////////////////////////////////////////////////////////////////////////
  14. #define LITTLE_ENDIAN
  15. #define TRUE 1
  16. #define FALSE 0
  17. #if !defined(NULL)
  18. #define NULL ((void *) 0)
  19. #endif
  20. #define MAX_UCHAR 0xFF
  21. #define MAX_SCHAR 0x7F
  22. #define MIN_SCHAR 0x80
  23. #define MAX_SHORT 0x7FFF
  24. #define MIN_SHORT 0x8000
  25. #define MAX_USHORT 0xFFFF
  26. #define MAX_SSHORT 0x7FFF
  27. #define MIN_SSHORT 0x8000
  28. #define MAX_LONG 0x7FFFFFFF
  29. #define MIN_LONG 0x80000000
  30. #define MAX_ULONG 0xFFFFFFFF
  31. #define MAX_SLONG 0x7FFFFFFF
  32. #define MIN_SLONG 0x80000000
  33. #if !defined(BASETYPES) // windef.h compatibility
  34. typedef unsigned char BOOL;
  35. #endif
  36. typedef unsigned char UCHAR;
  37. typedef signed char SCHAR;
  38. typedef short SHORT;
  39. typedef unsigned short USHORT;
  40. typedef signed short SSHORT;
  41. #if !defined(LONG)
  42. typedef long LONG;
  43. #endif
  44. typedef unsigned long ULONG;
  45. typedef signed long SLONG;
  46. typedef float FLOAT;
  47. typedef double DOUBLE;
  48. typedef union
  49. {
  50. USHORT usData;
  51. struct
  52. {
  53. #if defined(LITTLE_ENDIAN)
  54. UCHAR ucLow;
  55. UCHAR ucHigh;
  56. #elif defined(BIG_ENDIAN)
  57. UCHAR ucHigh;
  58. UCHAR ucLow;
  59. #else
  60. #error
  61. #endif
  62. } stBytes;
  63. } USHORT_UNION;
  64. typedef union
  65. {
  66. ULONG ulData;
  67. struct
  68. {
  69. // The least significant byte of the ULONG in this structure is
  70. // referenced by ucByte0.
  71. #if defined(LITTLE_ENDIAN)
  72. UCHAR ucByte0;
  73. UCHAR ucByte1;
  74. UCHAR ucByte2;
  75. UCHAR ucByte3;
  76. #elif defined(BIG_ENDIAN)
  77. UCHAR ucByte3;
  78. UCHAR ucByte2;
  79. UCHAR ucByte1;
  80. UCHAR ucByte0;
  81. #else
  82. #error
  83. #endif
  84. } stBytes;
  85. } ULONG_UNION;
  86. #endif // !TYPES_H