Skip to content

Exception: Unable to find out actual class definition: '_VectorArgs'. #151

Open
@kingyuguo

Description

@kingyuguo

I use pygccxml to parse Google FlatBuffers (flatbuffers/tests/monster_test_generated.h) with the following configuration:

xml_generator_config = parser.xml_generator_configuration_t(
        xml_generator_path=generator_path,
        xml_generator=generator_name,
        include_paths = ["include","3rd_party/flatbuffers/include"],
        compiler='g++',
        cflags = "-std=c++11"
        )

then error occured:

INFO Parsing source file "3rd_party/flatbuffers/tests/monster_test_generated.h" ...
In file included from 3rd_party/flatbuffers/tests/monster_test_generated.h:7:
In file included from 3rd_party/flatbuffers/include/flatbuffers/flatbuffers.h:20:
3rd_party/flatbuffers/include/flatbuffers/base.h:311:1: warning: unknown attribute 'no_sanitize_undefined' ignored [-Wunknown-attributes]
__supress_ubsan__("alignment")
^
3rd_party/flatbuffers/include/flatbuffers/base.h:216:50: note: expanded from macro '__supress_ubsan__'
  #define __supress_ubsan__(type) __attribute__((no_sanitize_undefined))
                                                 ^
3rd_party/flatbuffers/include/flatbuffers/base.h:318:1: warning: unknown attribute 'no_sanitize_undefined' ignored [-Wunknown-attributes]
__supress_ubsan__("alignment")
^
3rd_party/flatbuffers/include/flatbuffers/base.h:216:50: note: expanded from macro '__supress_ubsan__'
  #define __supress_ubsan__(type) __attribute__((no_sanitize_undefined))
                                                 ^
In file included from 3rd_party/flatbuffers/tests/monster_test_generated.h:8:
In file included from 3rd_party/flatbuffers/include/flatbuffers/flexbuffers.h:24:
3rd_party/flatbuffers/include/flatbuffers/util.h:256:1: warning: unknown attribute 'no_sanitize_undefined' ignored [-Wunknown-attributes]
__supress_ubsan__("float-cast-overflow")
^
3rd_party/flatbuffers/include/flatbuffers/base.h:216:50: note: expanded from macro '__supress_ubsan__'
  #define __supress_ubsan__(type) __attribute__((no_sanitize_undefined))
                                                 ^
3 warnings generated.
Traceback (most recent call last):
  File "parser.py", line 29, in <module>
    decls = parser.parse([filename], xml_generator_config)
  File "/home/research/anaconda3/lib/python3.8/site-packages/pygccxml/parser/__init__.py", line 51, in parse
    declarations = parser.read_files(files, compilation_mode)
  File "/home/research/anaconda3/lib/python3.8/site-packages/pygccxml/parser/project_reader.py", line 264, in read_files
    return self.__parse_file_by_file(files)
  File "/home/research/anaconda3/lib/python3.8/site-packages/pygccxml/parser/project_reader.py", line 335, in __parse_file_by_file
    self._relink_declarated_types(leaved_classes, types)
  File "/home/research/anaconda3/lib/python3.8/site-packages/pygccxml/parser/project_reader.py", line 566, in _relink_declarated_types
    raise Exception(os.linesep.join(msg))
Exception: Unable to find out actual class definition: '_VectorArgs'.
Class definition has been changed from one compilation to an other.
Why did it happen to me? Here is a short list of reasons:
    1. There are different preprocessor definitions applied on same file during compilation
    2. Bug in pygccxml.

I looked in the file "monster_test_generated.h" and I found some code like this:

inline flatbuffers::Offset<TestSimpleTableWithEnum> CreateTestSimpleTableWithEnum(flatbuffers::FlatBufferBuilder &_fbb, const TestSimpleTableWithEnumT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
  (void)_rehasher;
  (void)_o;
  struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const TestSimpleTableWithEnumT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
  auto _color = _o->color;
  return MyGame::Example::CreateTestSimpleTableWithEnum(
      _fbb,
      _color);
}
inline flatbuffers::Offset<Stat> CreateStat(flatbuffers::FlatBufferBuilder &_fbb, const StatT *_o, const flatbuffers::rehasher_function_t *_rehasher) {
  (void)_rehasher;
  (void)_o;
  struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const StatT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
  auto _id = _o->id.empty() ? 0 : _fbb.CreateString(_o->id);
  auto _val = _o->val;
  auto _count = _o->count;
  return MyGame::Example::CreateStat(
      _fbb,
      _id,
      _val,
      _count);
}

is this a bug of pygccxml?thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions