QSharedDataPointer and QSharedData compile problem
-
Hi all, i have some problem with compiling such code
// This is main shared library of my app
in *.h file :@class GroupData; // which is in groupdata.h and included in group.cpp
class Group
{
public:
Group();
Group( const Group &other );
...
private:
QSharedDataPointer<GroupData> d;
};
@
@
//------------------------------------------------------------------------
// GroupData in separate groupdata.h
class GroupData
{
public:
GroupData(){}
GroupData( const GroupData &other ):QSharedData(other),
title(other.title){}~GroupData(){...} ... QString title;
}
// this compile, without problems
@Problem starts when i include main lib in another shared library, gcc says that the: forward declaration of 'struct GroupData'
Myabe i am something missed ?
-
In other library i error in next line :
@QList<Group> groups;
groups.push_back(group);@ -
from my experience, you shouldn't use forward declarations in combination with shared pointers, smart pointers, etc.
When compiling the template, problems can arise when it comes to resolving the destructor the pointer should call (the compiler doesn't know the destructor due to the forward declaration).I'm guessing this is GCC's way of telling you not to do this...
-
Yes, it claims also about destructor will not be called. But when how to hide privat shared data. And Qt docs says that putting private shared data in seperate class is common use.