TransformNode with 4 bytes to alignment boundary
そして、この警告を引き起こすコードは次のとおりです。
class TransformNode : public Node {
public:
int number;
public:
void test() { number = 12; }
};
//Node.h
class Node {
public:
typedef std::set<Node *> ChildSet;
protected:
ChildSet mChildren;
Node * mParent;
public:
Node(Node * parent=0) : mParent(parent) {}
~Node() {}
Node * addChild(Node * node);
inline Node * getParent() { return mParent; }
const ChildSet &getChildren() const { return mChildren; }
};
inline void node_test() {
TransformNode * node = new TransformNode;
node->test();
std::cout << node->number << "\n";
}
int main() {
node_test();
return 0;
}
クラスTransformNodeからNodeクラスを派生させると、エラーが発生します。すべての警告をオンにして xcode 5.0 を使用し、警告をエラーとして扱っています。このコードで何が起こっているのかを本当に理解したいので、警告をオフにするか、警告をエラーとして扱うのをやめるだけでは、これを処理したくありません。
編集: コードを追加しました。詳細の説明(太字)
ありがとう、
ガシム