【问题标题】:error C4430: missing type specifier - int assumed?错误 C4430:缺少类型说明符 - 假定为 int?
【发布时间】:2014-06-23 09:59:43
【问题描述】:

我写了一个回调方法,当我尝试在vs2012中编译项目时,出现以下错误:

 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
 error C2143: syntax error : missing ',' before '&'

这两个错误都出现在同一行中。

这些是我正在尝试的以下代码:

#include <windows.h>
#include "atlstr.h"

///////////////////////////////////////////////////////////////////////////////
class CInf;
typedef BOOL (*PENUMDEVCALLBACK)(CInf* inf, const CString& devname, const CString& instsecname, const CStringArray& devid, PVOID context, DWORD& code);

我认为错误将出现在CStringArray&amp; 参数中,因为当我包含afxcoll.h 时。

the fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include &lt;windows.h&gt;.

当我删除 windows.h 时。上述错误消失了,但我还需要 windows.h 标头。

知道如何在同一个文件中包含windows.h 和afxcoll.h。

【问题讨论】:

  • 我相信你应该包括afx.h然后afxcoll.h。前者(间接)包括windows.h

标签: windows visual-c++ visual-studio-2012 mfc


【解决方案1】:

不可能只包括 MFC 的孤立部分。当您想使用 CStringArray 时,您需要包含 afx.h 或 afxwin.h 文件。

可以单独使用 CString。如果您只想要一个 CString 数组并且不需要完整的 MFC,那么使用 std::vector 会更容易。 CString 与所有 STL 容器完美配合。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-12-04
    • 2014-06-10
    • 1970-01-01
    • 2017-03-28
    • 1970-01-01
    • 2015-05-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多