2

我需要为基于 Zinc 的 Flash 应用程序重构一个 .dll。

在将一个类从 master 复制并粘贴到分支后,我遇到了一些奇怪的编译错误:

GameInfo.h(15): error C2146: syntax error : missing ';' before identifier 'm_wsVersion'
GameInfo.h(15): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
GameInfo.h(15): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

寻址代码:

// removed the comments
#include "stdafx.h"
#include <string.h>

class GameInfo {

public:

    UINT m_uiGameId;

    wstring m_wsVersion; // Line 15

    UINT m_uiCheckSum;

    wstring m_wsFilePath; // Same error report as on line 15

public:
    static BOOL createFromFile(wstring path, GameInfo &target); // error "error C2061: syntax error : identifier 'wstring'" thrown
};

我使用 Visual Studio 2010,在 IDE 本身中一切正常,没有语法错误或类似的错误。如前所述,我没有接触代码,标题似乎很好。

有谁知道这个错误怎么办?

4

2 回答 2

5

尝试使用字符串标头,并限定命名空间:

#include <string>

class GameInfo {
   ....  
   std::wstring m_wsVersion;
};
于 2012-06-08T10:58:34.013 回答
2

#include <string>是 C++ 中包含字符串类和使用的正确标准std::wstring

我强烈建议 AGAINST 使用using namespace std;您的标题之一,因为您会强制使用标题的任何人将 std 内容拉入全局命名空间。

于 2012-06-08T10:58:16.750 回答