From 3c2bac089a9f997489d4e21f0db164cb42625deb Mon Sep 17 00:00:00 2001 From: Anisa Su Date: Tue, 18 Nov 2025 18:38:05 +0000 Subject: [PATCH] cursorhandler.py: remove inaccurate warning clang gives flex array members a size of -2, which means the bad source code warning generated when checking if bits < 0 is always generated for flex arrays. clang only assigns flex arrays a negative size. Therefore, this warning will never be generated for non flex arrays, which renders it inaccurate. Signed-off-by: Anisa Su --- ctypeslib/codegen/cursorhandler.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ctypeslib/codegen/cursorhandler.py b/ctypeslib/codegen/cursorhandler.py index ce08ebe..8bcde9b 100644 --- a/ctypeslib/codegen/cursorhandler.py +++ b/ctypeslib/codegen/cursorhandler.py @@ -1027,7 +1027,8 @@ def FIELD_DECL(self, cursor): else: bits = cursor.type.get_size() * 8 if bits < 0: - log.warning('Bad source code, bitsize == %d <0 on %s', bits, name) + # Flex array members have a size of -2 + # log.warning('Bad source code, bitsize == %d <0 on %s', bits, name) bits = 0 log.debug('FIELD_DECL: field is %d bits', bits) # try to get a representation of the type