summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWouter van Oortmerssen <aardappel@gmail.com>2017-01-13 18:30:57 -0800
committerWouter van Oortmerssen <aardappel@gmail.com>2017-01-13 18:30:57 -0800
commit19101826a80b415680738cf3722ee02a0b0c8565 (patch)
tree5ac4d7ac2c24b8ab9168076d58eb423e7ace7539 /src
parent7b94eab2b14be37b2134cdb6cb51a2c30cee89eb (diff)
downloadflatbuffers-19101826a80b415680738cf3722ee02a0b0c8565.tar.gz
flatbuffers-19101826a80b415680738cf3722ee02a0b0c8565.tar.bz2
flatbuffers-19101826a80b415680738cf3722ee02a0b0c8565.zip
Fix unused field warning in clang.
Change-Id: I71d590a1e5b2709f0e2dcf97faaebda5cb918fc7 Tested: on Linux.
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: