From 83f701a374f8a287cc8f02826e095614df615fff Mon Sep 17 00:00:00 2001 From: djazz Date: Mon, 26 Jun 2023 06:51:12 +0200 Subject: [PATCH] fix value zero (#74) --- src/opir.nim | 1 + tests/tstdint.h | 1 + tests/tstdint.nim | 1 + 3 files changed, 3 insertions(+) diff --git a/src/opir.nim b/src/opir.nim index 6299920..3d63517 100644 --- a/src/opir.nim +++ b/src/opir.nim @@ -380,6 +380,7 @@ proc genMacroDecl(macroDef: CXCursor): JsonNode = of 'x', 'X': parseReturn(HexInt, def.replace("'", ""), kind) of 'b', 'B': parseReturn(BinInt, def.replace("'", ""), kind) of '1'..'9': parseReturn(OctInt, def[1..^1].replace("'", ""), kind) + of 'u', 'U', 'l', 'L', 'z', 'Z': parseReturn(BiggestInt, def, kind) else: discard of '-': parseReturn(BiggestInt, def.replace("'", ""), kind) of '1'..'9': parseReturn(BiggestInt, def.replace("'", ""), kind); parseReturn(BiggestUInt, def.replace("'", ""), kind) diff --git a/tests/tstdint.h b/tests/tstdint.h index 8361b96..06b7502 100644 --- a/tests/tstdint.h +++ b/tests/tstdint.h @@ -3,6 +3,7 @@ // Adapted from usage in the wild: // https://github.com/boschsensortec/BME68x-Sensor-API/blob/master/bme68x_defs.h +#define TEST_UINT8_ZERO UINT8_C(0) #define TEST_UINT8 UINT8_C(0xff) #define TEST_UINT16 UINT16_C(0xffff) #define TEST_UINT32 UINT32_C(0xffffffff) diff --git a/tests/tstdint.nim b/tests/tstdint.nim index e4f57bb..4733cf5 100644 --- a/tests/tstdint.nim +++ b/tests/tstdint.nim @@ -4,6 +4,7 @@ importc: path "." "tstdint.h" +doAssert TEST_UINT8_ZERO == 0'u8.uint8 doAssert TEST_UINT8 == 0xff'u8.uint8 doAssert TEST_UINT16 == 0xffff'u16.cuint doAssert TEST_UINT32 == 0xffffffff'u32.culong