c++ - Compilation error Friend class unable to access field -
i trying compile qt5.3
files in question qv4executableallocator_p.h , qv4executableallocator.cpp. relevant code snippet header below
struct allocation{ allocation() : addr(0) , size(0) , free(true) , next(0) , prev(0) {} void *start() const; void invalidate() { addr = 0; } bool isvalid() const { return addr != 0; } void deallocate(executableallocator *allocator); private: ~allocation() {} friend class executableallocator; allocation *split(size_t dividingsize); bool mergenext(executableallocator *allocator); bool mergeprevious(executableallocator *allocator); quintptr addr; uint size : 31; // more 2gb of function code? nah :) uint free : 1; allocation *next; allocation *prev; };
in cpp function executableallocator::chunkofpages::~chunkofpages()
compilation error when trying access alloc->next.
qv4::executableallocator::allocation* qv4::executableallocator::allocation::next’ private
code can seen online @ https://qt.gitorious.org/qt/qtdeclarative/source/be6c91acc3ee5ebb8336b9e79df195662ac11788:src/qml/jsruntime
my gcc version relatively old... 4.1
issue or else wrong in environment. way go forward. stuck compiler, since 1 have use on target platform
i'd guess qv4::executableallocator::chunkofpages
struct not directly befriended allocation
, can't access allocation
's private data in destructor in c++ prior c++11 standard.
try adding friend struct executableallocator::chunkofpages
allocation
definition, should trick.
there slight change in way nested classes handled in c++11 (cited cppreference.com):
prior c++11, member declarations , definitions inside nested class of friend of class t cannot access private , protected members of class t, compilers accept in pre-c++11 mode.
which explain why worked in new compiler, not in old one.
Comments
Post a Comment