mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-28 19:00:03 +00:00
Add no-op for padding variables to prevent clang compiler warning.
Change-Id: I119ee7109bfa2b0be0f468d2b2be459f45d1bb11
This commit is contained in:
@@ -1618,16 +1618,16 @@ class CppGenerator : public BaseGenerator {
|
|||||||
NumToString((*id)++) + "__;";
|
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) {
|
static void PaddingInitializer(int bits, std::string *code_ptr, int *id) {
|
||||||
(void)bits;
|
(void)bits;
|
||||||
*code_ptr += ",\n padding" + NumToString((*id)++) + "__(0)";
|
*code_ptr += ",\n padding" + NumToString((*id)++) + "__(0)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void PaddingNoop(int bits, std::string *code_ptr, int *id) {
|
||||||
|
(void)bits;
|
||||||
|
*code_ptr += " (void)padding" + NumToString((*id)++) + "__;";
|
||||||
|
}
|
||||||
|
|
||||||
// Generate an accessor struct with constructor for a flatbuffers struct.
|
// Generate an accessor struct with constructor for a flatbuffers struct.
|
||||||
void GenStruct(const StructDef &struct_def) {
|
void GenStruct(const StructDef &struct_def) {
|
||||||
// Generate an accessor struct, with private variables of the form:
|
// Generate an accessor struct, with private variables of the form:
|
||||||
@@ -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("ARG_LIST", arg_list);
|
||||||
code_.SetValue("INIT_LIST", init_list);
|
code_.SetValue("INIT_LIST", init_list);
|
||||||
code_.SetValue("PADDING_LIST", padding_list);
|
|
||||||
code_ += " {{STRUCT_NAME}}({{ARG_LIST}})";
|
code_ += " {{STRUCT_NAME}}({{ARG_LIST}})";
|
||||||
code_ += " : {{INIT_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_ += " }";
|
code_ += " }";
|
||||||
|
|
||||||
// Generate accessor methods of the form:
|
// Generate accessor methods of the form:
|
||||||
|
|||||||
@@ -200,7 +200,9 @@ MANUALLY_ALIGNED_STRUCT(16) Vec3 FLATBUFFERS_FINAL_CLASS {
|
|||||||
padding1__(0),
|
padding1__(0),
|
||||||
test3_(_test3),
|
test3_(_test3),
|
||||||
padding2__(0) {
|
padding2__(0) {
|
||||||
(void)padding0__;(void)padding1__;(void)padding2__;
|
(void)padding0__;
|
||||||
|
(void)padding1__;
|
||||||
|
(void)padding2__;
|
||||||
}
|
}
|
||||||
float x() const {
|
float x() const {
|
||||||
return flatbuffers::EndianScalar(x_);
|
return flatbuffers::EndianScalar(x_);
|
||||||
|
|||||||
Reference in New Issue
Block a user