Solved Alignment boundary issue
-
Hi,
I define a class something like below :
class LayerInformation { public: LayerInformation(); LayerInformation(QString *name,bool *isVisible,QString *dateOfCreation,QString *description); QString name() const; bool isVisible() const; QString date_of_creation() const; QString description() const; void setName(const QString &name); void setIsVisible(bool isVisible); void setDate_of_creation(const QString &date_of_creation); void setDescription(const QString &description); private: QString m_name; QString m_date_of_creation; QString m_description; bool m_isVisible; }; Q_DECLARE_METATYPE(LayerInformation)
but the compiler complain about padding size:
"Padding size of LayerInformation with 3 bytes to alignment boundary"
It's warning not an error but I want to fix this and I don't know why I face to this message!? -
@Alien ,
It can solve by adding 3 bytes in the private variable something like:
char m_padding[3];
or use #pragma pack(1) instead(It can cause performance issues). -
@Alien Tell us more about your development environment, OS, compiler name and version. This is quite certainly compiler dependent. And it's always recommended to copypaste the exact message lines and some context.
-
@Eeli-K ,
sorry
OS:Windows 7 x64
QT SDK: 5.8.0 MinGW 32bit
And I want to use this in Qt Quick
Thanks, -
-
@Eeli-K ,
So how to solve this? -
@Alien ,
It can solve by adding 3 bytes in the private variable something like:
char m_padding[3];
or use #pragma pack(1) instead(It can cause performance issues).