c++中wstring的编译问题

Joh*_*auß 2 c++ visual-studio-2010 wstring

我需要为基于锌的 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
Run Code Online (Sandbox Code Playgroud)

寻址代码:

// 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
};
Run Code Online (Sandbox Code Playgroud)

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

有没有人知道这个错误是怎么回事?

jua*_*nza 5

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

#include <string>

class GameInfo {
   ....  
   std::wstring m_wsVersion;
};
Run Code Online (Sandbox Code Playgroud)