Getting a "flatbuffers::Table::Table cannot access private member" error in C++

236 views
Skip to first unread message

edward rosales

unread,
Mar 10, 2015, 10:48:37 AM3/10/15
to flatb...@googlegroups.com
Hi,

As stated in the title i am getting an error C2248: "flatbuffers::Table::Table cannot access private member declared in class flatbuffers::Table" error in Visual Studio 2013 from my header generated from my .fbs, i have everything properly included and this error doesn't come up if I copy these files into another project. 

Can anyone give me any insight into why this is happening?

Regards,

Edward

Wouter van Oortmerssen

unread,
Mar 11, 2015, 3:25:44 PM3/11/15
to edward rosales, flatb...@googlegroups.com
Can you post sample code that produces this error? You would only get this error if you tried instantiating a Table, which you shouldn't ever need to do (see flatbuffers.h:1040).

--
You received this message because you are subscribed to the Google Groups "FlatBuffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flatbuffers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

edward rosales

unread,
Mar 11, 2015, 3:36:20 PM3/11/15
to flatb...@googlegroups.com, rosal...@gmail.com
Hi,

being as concise as I can since the code is company code.i have something similar to the code below:

#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/idl.h"
#include "flatbuffers/util.h"

#include ""SMP_generated.h"

flatbuffers::FlatBufferBuilder builder;

flatbuffers::Offset<Flatbuffer::BinaryMap::SMP> m_SMPA[MBS_MAX_MP];
Flatbuffer::BinaryMap::SMP m_MP[MBS_MAX_MAPPOINTS];

namespace AAA{

bool AssignMP(){
          Flatbuffer::BinaryMap::SMPBuilder mpx(builder);  //Map Point Info
          ...
          ... 
          ...
       }
}


something along those lines, any help would be appreciated.

Kind Regards,

Edward

Wouter van Oortmerssen

unread,
Mar 11, 2015, 4:33:19 PM3/11/15
to edward rosales, flatb...@googlegroups.com
The problem is in this line:

Flatbuffer::BinaryMap::SMP m_MP[MBS_MAX_MAPPOINTS];

You intantiate an SMP which inherits from Table. SMP is a helper class that helps you refer to objects inside FlatBuffers, they should never be instantiated outside of a FlatBuffer. Not sure what that array is for, but if anything they should be pointers.

edward rosales

unread,
Mar 11, 2015, 4:59:09 PM3/11/15
to flatb...@googlegroups.com, rosal...@gmail.com
Hi,

That was the problem thanks! I see in your test code when creating an array of tables you use this:

MonsterBuilder mb1(builder);
  mb1.add_name(fred);
  mlocs[0] = mb1.Finish();
  MonsterBuilder mb2(builder);
  mb2.add_name(barney);
  mlocs[1] = mb2.Finish();
  MonsterBuilder mb3(builder);
  mb3.add_name(wilma);
  mlocs[2] = mb3.Finish();


what would be the best approach if i have a variable size of monsters but i still want to make an array of tables?

Wouter van Oortmerssen

unread,
Mar 13, 2015, 4:11:54 PM3/13/15
to edward rosales, flatb...@googlegroups.com
Note that flatbuffers::Offset<> is the type you use to refer to an object when you're constructing a FlatBuffer, and anything derived from Table is how you refer to objects when reading a FlatBuffer.

Reply all
Reply to author
Forward
0 new messages