google / flatbuffers

FlatBuffers: Memory Efficient Serialization Library

Home Page:http://google.github.io/flatbuffers/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[C++] flatc generates invalid Code in the default constructor for structs, when --cpp-field-case-style is used

stefan301 opened this issue · comments

When --cpp-field-case-style upper or --cpp-field-case-style lower is used for the following schema, flatc generates invalid code:

struct Guid {
    data1 : uint32;
    data2 : uint16;
    data3 : uint16;
    data4_0 : uint8;
    data4_1 : uint8;
    data4_2 : uint8;
    data4_3 : uint8;
    data4_4 : uint8;
    data4_5 : uint8;
    data4_6 : uint8;
    data4_7 : uint8;
}

flatc.exe --cpp --cpp-field-case-style lower Guid.fbs

generates this Code:

FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Guid FLATBUFFERS_FINAL_CLASS {
 private:
  uint32_t data1_;
  uint16_t data2_;
  uint16_t data3_;
  uint8_t data40_;
  uint8_t data41_;
  uint8_t data42_;
  uint8_t data43_;
  uint8_t data44_;
  uint8_t data45_;
  uint8_t data46_;
  uint8_t data47_;

 public:
  Guid()
      : data1_(0),
        data2_(0),
        data3_(0),
        data4_0_(0),
        data4_1_(0),
        data4_2_(0),
        data4_3_(0),
        data4_4_(0),
        data4_5_(0),
        data4_6_(0),
        data4_7_(0) {
  }
  Guid(uint32_t _data1, uint16_t _data2, uint16_t _data3, uint8_t _data40, uint8_t _data41, uint8_t _data42, uint8_t _data43, uint8_t _data44, uint8_t _data45, uint8_t _data46, uint8_t _data47)
      : data1_(flatbuffers::EndianScalar(_data1)),
        data2_(flatbuffers::EndianScalar(_data2)),
        data3_(flatbuffers::EndianScalar(_data3)),
        data40_(flatbuffers::EndianScalar(_data40)),
        data41_(flatbuffers::EndianScalar(_data41)),
        data42_(flatbuffers::EndianScalar(_data42)),
        data43_(flatbuffers::EndianScalar(_data43)),
        data44_(flatbuffers::EndianScalar(_data44)),
        data45_(flatbuffers::EndianScalar(_data45)),
        data46_(flatbuffers::EndianScalar(_data46)),
        data47_(flatbuffers::EndianScalar(_data47)) {
  }
ezoic increase your site revenue