summaryrefslogtreecommitdiff
path: root/tests/headers/disable-nested-struct-naming.h
diff options
context:
space:
mode:
authoroblique <psyberbits@gmail.com>2019-09-17 21:44:34 +0300
committerEmilio Cobos Álvarez <emilio@crisal.io>2019-10-22 22:21:21 +0200
commitcb8266620596222b1cd9dbe6551cc1e3e8bb7f72 (patch)
tree9c7d92dab2c58a23f395cb23ac833c5f45285155 /tests/headers/disable-nested-struct-naming.h
parentfa6a68d7c768cd9d4efc418f5d8d9ceb104704ad (diff)
Add `disable_nested_struct_naming` option (#1610)
The following structs have different names for C and C++. In case of C they are visible as `foo` and `bar`. In case of C++ they are visible as `foo` and `foo::bar`. By default bindgen follows C++ naming to avoid generating duplicate names. With this option the following structs will be named as `foo` and `bar` instead of `foo` and `foo_bar`. ``` struct foo { struct bar { } b; }; ``` In case of an unnamed definition we build the canonical name from the inner most named definition. For example the following will generate `baz__bindgen_ty_1`: ``` struct foo { struct bar { struct baz { struct { } u; } z; } b; }; ``` This option should be used only for C headers. It is needed in some rare situations where user used another code generator that already mangled nested definitions. A real life example is [asn1c] with `-fcompound-names` option. [asn1c]: https://github.com/vlm/asn1c
Diffstat (limited to 'tests/headers/disable-nested-struct-naming.h')
-rw-r--r--tests/headers/disable-nested-struct-naming.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/headers/disable-nested-struct-naming.h b/tests/headers/disable-nested-struct-naming.h
new file mode 100644
index 00000000..0e4fccb6
--- /dev/null
+++ b/tests/headers/disable-nested-struct-naming.h
@@ -0,0 +1,24 @@
+// bindgen-flags: --disable-nested-struct-naming
+
+struct foo {
+ struct bar1 {
+ int x1;
+ struct {
+ int x2;
+ struct {
+ int x3;
+ struct bar4 {
+ int x4;
+ } b4;
+ } b3;
+ } b2;
+ } b1;
+};
+
+struct {
+ struct {
+ struct baz {
+ int x;
+ } b;
+ } anon2;
+} anon1;