Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Invalid generated namespace for "CreateXXX" function for native_type table field #8915

@T-Maxxx

Description

@T-Maxxx

Flatbuffers v25.12.19 (master@af8997b5 too).

Consider having two fbs schemas, basic.fbs:

native_include "Bitmap.hpp"; // native basic::Bitmap implementation.

namespace basic.fbs; // have to place (basic::fbs::BitmapT) to other namespace than basic::Bitmap

table Bitmap(native_type:"basic::Bitmap") {
    buffer:[uint64];
}

And includer one schema in a different directory hierarchy, includer.fbs:

include "basic.fbs";

namespace includer; // expect to have includer::TableT

table Table {
    bm:basic.fbs.Bitmap (required);
}

Generating with object API and proper include directory for includer schema (to get include instruction work) produces invalid reference to CreateBitmap function in includer_generated.h:

namespace includer {
// ...
inline ::flatbuffers::Offset<Table> Table::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const TableT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
  (void)_rehasher;
  (void)_o;
  struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const TableT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
  auto _bm = _o->bm ? CreateBitmap(_fbb, _o->bm.get(), _rehasher) : 0;
  return includer::CreateTable(
      _fbb,
      _bm);
}
...
} // namespace includer

Compiler error:

/[REDACTED]/Table_generated.h: error: use of undeclared identifier 'CreateBitmap'; did you mean 'basic::fbs::CreateBitmap'?
 1454 |   auto _bm = _o->bm ? CreateBitmap(_fbb, _o->bm.get(), _rehasher) : 0;
      |                       ^~~~~~~~~~~~
      |                       ::basic::fbs::CreateBitmap
/[REDACTED 2]/basic_generated.h: note: 'basic::fbs::CreateBitmap' declared here
   96 | inline ::flatbuffers::Offset<Bitmap> CreateBitmap(::flatbuffers::FlatBufferBuilder &_fbb, const basic::Bitmap *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
      |                                      ^

Note: adding compiler suggested namespaces manually gives me expected (according to docs) linker errors

error: undefined symbol: basic::fbs::Bitmap::Pack(flatbuffers::FlatBufferBuilderImpl<false>&, basic::Bitmap const*, std::__1::function<unsigned long (void*)> const*)
error: undefined symbol: basic::fbs::Bitmap::UnPackTo(basic::Bitmap*, std::__1::function<void (void**, unsigned long)> const*) const

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