Windows.h已经包含在afxv_w32.h - CString

windows.h already included afxv_w32.h - CString

本文关键字:w32 CString afxv 包含 Windows      更新时间:2023-10-16

我试图在我的 cpp 文件中包含 CString,但如果我包含 afxinet.h 会收到此错误

"Windows.H 已包含 afxv_w32.h"

这些是我的头文件:

#include stdafx.h

#include 什尔瓦皮·

#include Tlhelp32.h

#include 钩子.h

#include stdio.h

#include 常见1.h

#include 安全记录器

#include

#include tinyxml.h

#include Winsock.h>

#pragma 注释(lib, "Ws2_32.lib")

#include afxinet.h

我还没有将葫芦包含在堆栈中以显示在这里。

如何解决此问题并将CString包含在我的文件中

如果你想要CString,为什么要添加afxinet.h

应包含atlstr.h才能获得CString - 尤其是在项目不是基于 MFC 的情况下。

在C++设置中使用/showIncludes选项(在"高级"下)。这将显示如何包含标头(以树格式)。作为另一个建议,您应该只包含所需的文件。

通过包含 afx.h><,您应该能够在 cpp 文件中使用 CString 类。

#include <afx.h>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
    CString str("Santosh");
    wcout << LPCTSTR(str) << endl;
    return 0;
}
Additionally, you will need to define _AFXDLL preprocessor