尝试使旧代码工作时在CString上使用typedef时出错

时间:2010-06-23 14:52:19

标签: c++ cstring

我有一些用于控制wifi模块的示例代码,告诉我使用VC 6.0,并且不支持更新的版本。无论如何,我正试图让它发挥作用。它使用CString,它是MFC的一部分,所以我下载了一个Visual Studio 2010试用版,看看我是否可以编译它。 这是抛出(开始)错误的代码:

#ifdef _UNICODE  
//Use CString as the standard string type in UNICODE versions
typedef CString WuString; // Line 42
#endif

这是错误消息:

1>d:\...\my documents\authapiex\apps8.0.0.90_sdk_xp\include\wtypes.h(42): error C2146: syntax error : missing ';' before identifier 'WuString'
1>d:\...\my documents\authapiex\apps8.0.0.90_sdk_xp\include\wtypes.h(42): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\...\my documents\authapiex\apps8.0.0.90_sdk_xp\include\wtypes.h(42): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

任何帮助都会很棒。

2 个答案:

答案 0 :(得分:0)

您缺少CString的包含。

#include <afx.h>

答案 1 :(得分:0)

看起来CString没有在你输入typedef的位置定义。您需要确保在typedef之前包含相应的包含文件。