Skip to content

Commit 942b62c

Browse files
tyalieandreax79
authored andcommitted
Enum: use signed instead of unsigned int for enum representation
This hits upon a larger issue. It doesn't seem fully clear what type a compiler will use to represent an enum, but signed integer seems to be a good enough solution as enum-constants (not the enum itself) are defined as int signed. See following patch note https://gcc.gnu.org/legacy-ml/gcc-patches/2000-07/msg00993.html Signed-off-by: Sophie Tyalie <dev@flowerpot.me>
1 parent 2e9836c commit 942b62c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

cstruct/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@
9494
}
9595

9696
ENUM_SIZE_TO_C_TYPE: Dict[int, str] = {
97-
1: 'uint8',
98-
2: 'uint16',
99-
4: 'uint32',
100-
8: 'uint64'
97+
1: 'int8',
98+
2: 'int16',
99+
4: 'int32',
100+
8: 'int64'
101101
}
102102

103103
CHAR_ZERO = bytes('\0', 'ascii')

0 commit comments

Comments
 (0)