嗨,在这个问题中,我读到编译顺序无关紧要,但我的情况很奇怪。
我在 CCSizePolicy.cpp 文件中有几个全局变量它们看起来像这样:
const CCSizePolicy CCSizePolicyWrapContent ( Const::WRAP_CONTENT );
const CCSizePolicy CCSizePolicyMatchContent ( Const::MATCH_PARENT );
const CCSizePolicy CCSizePolicyZero ( Policy::SP, 0 );
在标题中
enum Const
{
WRAP_CONTENT = -1, MATCH_PARENT = -2
};
extern const CCSizePolicy CCSizePolicyWrapContent;
extern const CCSizePolicy CCSizePolicyMatchContent;
extern const CCSizePolicy CCSizePolicyZero;
同样在 CCLayoutParams.h
extern const CCLayoutParams CCLayoutParamsMatchMatch;
extern const CCLayoutParams CCLayoutParamsWrapWrap;
extern const CCLayoutParams CCLayoutParamsMatchWrap;
extern const CCLayoutParams CCLayoutParamsWrapMatch;
和 CCLayoutParams.cpp
const CCLayoutParams CCLayoutParamsMatchMatch ( CCSizePolicyMatchContent,
CCSizePolicyMatchContent );
const CCLayoutParams CCLayoutParamsWrapWrap ( CCSizePolicyWrapContent,
CCSizePolicyWrapContent );
const CCLayoutParams CCLayoutParamsMatchWrap ( CCSizePolicyMatchContent,
CCSizePolicyWrapContent );
const CCLayoutParams CCLayoutParamsWrapMatch ( CCSizePolicyWrapContent,
CCSizePolicyMatchContent );
所以当我在我的程序中使用它们时,我调用 CCLayoutParamsWrapWrap.getWidth() 和 CCLayoutParamsWrapWrap.getHeight()
这应该输出我 -1 -1 但我有 0 0 ...
makefile 中的顺序如下所示:
src/view/layout/CCLayoutParams.cpp\
...
src/view/CCSizePolicy.cpp\
当我将其更改为
src/view/CCSizePolicy.cpp\
src/view/layout/CCLayoutParams.cpp\
...
一切都开始工作(我得到-1 -1)这是怎么回事?
我使用 gcc 版本 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) 的 Linux
我的整个项目都被窃听了,我不知道为什么,因为我按名称对源文件进行排序???!?!