summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/idl_gen_cpp.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp
index e6b6209b..587bb86a 100644
--- a/src/idl_gen_cpp.cpp
+++ b/src/idl_gen_cpp.cpp
@@ -1621,6 +1621,11 @@ class CppGenerator : public BaseGenerator {
NumToString((*id)++) + "__;";
}
+ static void PaddingDeclaration(int bits, std::string *code_ptr, int *id) {
+ (void)bits;
+ *code_ptr += "(void)padding" + NumToString((*id)++) + "__;";
+ }
+
static void PaddingInitializer(int bits, std::string *code_ptr, int *id) {
(void)bits;
*code_ptr += ",\n padding" + NumToString((*id)++) + "__(0)";
@@ -1702,10 +1707,20 @@ class CppGenerator : public BaseGenerator {
}
}
+ padding_id = 0;
+ std::string padding_list;
+ for (auto it = struct_def.fields.vec.begin();
+ it != struct_def.fields.vec.end(); ++it) {
+ auto field = *it;
+ GenPadding(*field, &padding_list, &padding_id, PaddingDeclaration);
+ }
+
code_.SetValue("ARG_LIST", arg_list);
code_.SetValue("INIT_LIST", init_list);
+ code_.SetValue("PADDING_LIST", padding_list);
code_ += " {{STRUCT_NAME}}({{ARG_LIST}})";
code_ += " : {{INIT_LIST}} {";
+ if (padding_list.length()) code_ += " {{PADDING_LIST}}";
code_ += " }";
// Generate accessor methods of the form: