Open porglezomp opened 2 months ago
hmmm... Well this is a hard one, clang
is convinced that _Bool
is the boolean type. If you pass this header to bindgen
_Bool example();
The AST produced by clang
will be
(
kind = FunctionDecl
spelling = "example"
location = input.h:1:7
is-definition? false
is-declaration? true
is-inlined-function? false
usr = "c:@F@example"
number-of-args = 0
ret-type = Bool
semantic-parent.kind = TranslationUnit
semantic-parent.spelling = "input.h"
semantic-parent.location = builtin definitions
semantic-parent.is-definition? false
semantic-parent.is-declaration? false
semantic-parent.is-inlined-function? false
type.kind = FunctionNoProto
type.cconv = 1
type.spelling = "_Bool ()"
type.is-variadic? true
type.return.kind = Bool
type.return.cconv = 100
type.return.spelling = "_Bool"
type.return.is-variadic? false
)
Where type.return.kind
is Bool
.
_Bool
is the canonical boolean type in C, bool
is a typedef from <stdbool.h>
.
I guess the question is does type.return.spelling
show for
#include <stdbool.h>
static inline bool example() { return 1; }
because I'm seeing the same in clang -Xclang -ast-dump -fsyntax-only
so maybe the sugared type isn't properly manifested :(
I'm seeing the same kind here using your example:
(
kind = FunctionDecl
spelling = "example"
location = hello3.c:2:20
is-definition? true
is-declaration? true
is-inlined-function? true
usr = "c:hello3.c@F@example"
number-of-args = 0
ret-type = Bool
semantic-parent.kind = TranslationUnit
semantic-parent.spelling = "hello3.c"
semantic-parent.location = builtin definitions
semantic-parent.is-definition? false
semantic-parent.is-declaration? false
semantic-parent.is-inlined-function? false
type.kind = FunctionNoProto
type.cconv = 1
type.spelling = "_Bool ()"
type.is-variadic? true
type.return.kind = Bool
type.return.cconv = 100
type.return.spelling = "_Bool"
type.return.is-variadic? false
...
I made a little wrapper header using
_Bool
to avoid having to includestdbool.h
since I was being lazy and didn't want to exclude a few symbols. It translated the_Bool
tobool
in thewrap-static-fns
generated wrapper, which caused a compilation failure.(Workaround: Just use stdbool. It’s not a big deal to filter out the few definitions.)
Input C/C++ Header
Bindgen Invocation
Actual Results
It generates this wrapper, with
_Bool
translated tobool
.which produces this error:
Expected Results
The generated wrappers should use
_Bool
as provided in the input.