@@ -42,37 +42,48 @@ extern const char *SDS_NOINIT;
42
42
43
43
typedef char * sds ;
44
44
45
+ #ifdef _MSC_VER
46
+ __pragma (pack (push , 1 ))
47
+ #define _SDS_PACKED
48
+ #else
49
+ #define _SDS_PACKED __attribute__ ((__packed__))
50
+ #endif
51
+
45
52
/* Note: sdshdr5 is never used, we just access the flags byte directly.
46
53
* However is here to document the layout of type 5 SDS strings. */
47
- struct __attribute__ (( __packed__ )) sdshdr5 {
54
+ struct _SDS_PACKED sdshdr5 {
48
55
unsigned char flags ; /* 3 lsb of type, and 5 msb of string length */
49
56
char buf [];
50
57
};
51
- struct __attribute__ (( __packed__ )) sdshdr8 {
58
+ struct _SDS_PACKED sdshdr8 {
52
59
uint8_t len ; /* used */
53
60
uint8_t alloc ; /* excluding the header and null terminator */
54
61
unsigned char flags ; /* 3 lsb of type, 5 unused bits */
55
62
char buf [];
56
63
};
57
- struct __attribute__ (( __packed__ )) sdshdr16 {
64
+ struct _SDS_PACKED sdshdr16 {
58
65
uint16_t len ; /* used */
59
66
uint16_t alloc ; /* excluding the header and null terminator */
60
67
unsigned char flags ; /* 3 lsb of type, 5 unused bits */
61
68
char buf [];
62
69
};
63
- struct __attribute__ (( __packed__ )) sdshdr32 {
70
+ struct _SDS_PACKED sdshdr32 {
64
71
uint32_t len ; /* used */
65
72
uint32_t alloc ; /* excluding the header and null terminator */
66
73
unsigned char flags ; /* 3 lsb of type, 5 unused bits */
67
74
char buf [];
68
75
};
69
- struct __attribute__ (( __packed__ )) sdshdr64 {
76
+ struct _SDS_PACKED sdshdr64 {
70
77
uint64_t len ; /* used */
71
78
uint64_t alloc ; /* excluding the header and null terminator */
72
79
unsigned char flags ; /* 3 lsb of type, 5 unused bits */
73
80
char buf [];
74
81
};
75
82
83
+ #ifdef _MSC_VER
84
+ __pragma (pack (pop ))
85
+ #endif
86
+
76
87
#define SDS_TYPE_5 0
77
88
#define SDS_TYPE_8 1
78
89
#define SDS_TYPE_16 2
0 commit comments