Skip to content

Commit 20a1e2f

Browse files
r41k0uclaude
andcommitted
Core: Accept c_bool as a ctypes type
c_bool was missing from the ctypes table, so c_bool(5) was an unknown call, its slot was never allocated, and the error read "Undefined variable". It is C's _Bool: one bit, like the True/False locals, never negative, and a value narrows to it by comparing with zero, which the signedness rules already apply to 1-bit types. It works as a local, a struct field, a map value and a global; in BTF it is a one-byte _Bool. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 4e8f767 commit 20a1e2f

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎pythonbpf/type_deducer.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ def signedness(ty) -> bool:
113113
"c_longlong": 64,
114114
# A pointer-sized integer; treated as unsigned like uintptr_t.
115115
"c_void_p": 64,
116+
# C's _Bool: one bit to LLVM (as True/False locals already are). It is
117+
# never negative, and a value narrows to it by comparing with zero.
118+
"c_bool": 1,
116119
}
117120

118121

0 commit comments

Comments
 (0)