summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWouter van Oortmerssen <aardappel@gmail.com>2017-01-18 16:16:17 -0800
committerWouter van Oortmerssen <aardappel@gmail.com>2017-01-18 16:17:08 -0800
commit42a265b4198149bfccc5fbde61c0f663c906eeaa (patch)
tree36fd3fccfac21a4f20266c301fa7ffaa7a06e34f /src
parent4bc4979acccdb6d4c9a43da856f8ef8e5ed23909 (diff)
downloadflatbuffers-42a265b4198149bfccc5fbde61c0f663c906eeaa.tar.gz
flatbuffers-42a265b4198149bfccc5fbde61c0f663c906eeaa.tar.bz2
flatbuffers-42a265b4198149bfccc5fbde61c0f663c906eeaa.zip
Add no-op for padding variables to prevent clang compiler warning.
Change-Id: I119ee7109bfa2b0be0f468d2b2be459f45d1bb11
Diffstat (limited to 'src')
-rw-r--r--src/idl_gen_cpp.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp
index 329e28a2..c21f6b31 100644
--- a/src/idl_gen_cpp.cpp
+++ b/src/idl_gen_cpp.cpp
@@ -1618,14 +1618,14 @@ class CppGenerator : public BaseGenerator {
NumToString((*id)++) + "__;";
}
- static void PaddingDeclaration(int bits, std::string *code_ptr, int *id) {
+ static void PaddingInitializer(int bits, std::string *code_ptr, int *id) {
(void)bits;
- *code_ptr += "(void)padding" + NumToString((*id)++) + "__;";
+ *code_ptr += ",\n padding" + NumToString((*id)++) + "__(0)";
}
- static void PaddingInitializer(int bits, std::string *code_ptr, int *id) {
+ static void PaddingNoop(int bits, std::string *code_ptr, int *id) {
(void)bits;
- *code_ptr += ",\n padding" + NumToString((*id)++) + "__(0)";
+ *code_ptr += " (void)padding" + NumToString((*id)++) + "__;";
}
// Generate an accessor struct with constructor for a flatbuffers struct.
@@ -1704,20 +1704,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}}";
+ padding_id = 0;
+ for (auto it = struct_def.fields.vec.begin();
+ it != struct_def.fields.vec.end(); ++it) {
+ const auto &field = **it;
+ if (field.padding) {
+ std::string padding;
+ GenPadding(field, &padding, &padding_id, PaddingNoop);
+ code_ += padding;
+ }
+ }
code_ += " }";
// Generate accessor methods of the form: