【发布时间】:2013-12-06 09:55:29
【问题描述】:
我正在开发一个 Blackberry 10 移动应用程序。使用momentics IDE(BB Native SDK)。
在我的应用程序中,我想使用许多类共享的全局变量。
我尝试了link 中描述的下面的代码,但是当我在变量“g_nValue*”在“.h”文件中,它返回错误“为'g_nValue'指定的存储类”
*/global.cpp:
// declaration of g_nValue
int g_nValue = 5;
*/global.h:
#ifndef GLOBAL_H // header guards
#define GLOBAL_H
// extern tells the compiler this variable is declared elsewhere
extern int g_nValue;
#endif
有人对此有想法吗?我搜了很多,他们都说extern指令应该不会造成任何麻烦。
【问题讨论】:
-
代码看起来正确。谷歌搜索这个错误,它可能看起来像you have a syntax error elsewhere in the file。
-
这是您的整个
global.h文件吗?在包含global.h之前包含什么?我怀疑缺少分号。
标签: c++ c qt qml blackberry-10