Skip to content
Snippets Groups Projects
Commit f9b8512d authored by Ingvar Stepanyan's avatar Ingvar Stepanyan Committed by Ryan Hunt
Browse files

Wrap tag into anonymous struct in C++

Fixes #122
parent 0ebcf99d
No related branches found
No related tags found
No related merge requests found
......@@ -357,7 +357,21 @@ impl Source for Enum {
out.open_brace();
}
// C++ allows accessing only common initial sequence of union
// branches so we need to wrap tag into an anonymous struct
let wrap_tag = config.language == Language::Cxx && !separate_tag;
if wrap_tag {
out.write("struct");
out.open_brace();
}
write!(out, "{} tag;", enum_name);
if wrap_tag {
out.close_brace(true);
}
out.new_line();
if separate_tag {
......
......@@ -34,7 +34,9 @@ union DisplayItem {
Rect bounds;
};
Tag tag;
struct {
Tag tag;
};
Fill_Body fill;
Image_Body image;
};
......
......@@ -56,7 +56,9 @@ union F {
int16_t y;
};
Tag tag;
struct {
Tag tag;
};
Foo_Body foo;
Bar_Body bar;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment