We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.
Macros like CC_KEYBOARD_SUPPORT should not be in header file
Macros like CC_KEYBOARD_SUPPORT should not be in header file
Refactor #2347 [Closed]
Status: | Closed | |
---|---|---|
Start date: | 2013-07-01 | |
Priority: | Normal | |
Due date: | ||
Assignee: | ||
% Done: | 100% |
|
Category: | all | |
Target version: | 3.0-alpha0-pre |
Refers to https://groups.google.com/forum/\#!topic/cocos2d-js-devel/HEJKYWXNXRU
Thanks Riq.
One thing that we should try to avoid, is adding “#ifdef XXXX” in the class definition.
The #ifdef should cover the whole class, or should be avoided.
Example:
// DANGER: Could lead to a potential bug very difficult to find.
class Node {
void addChild();
void removeChild();
#ifdef SUPPORT_FOR_XXX
void insertChild();
#endif
}
// BETTER: class interface (and vtable) is the same interface.
class Node {
void addChild();
void removeChild();
void insertChild();
}
Node::insertChild()
{
#ifdef SUPPORT_FOR_XXX
do….
#else
ASSERT (false, "NOT IMPLEMENTED");
#endif
}
The problem is when the “cocos2d” project is compiled as an static or dynamic lib with certain macro preprocessor, and the game is compiled with a different ones.