【问题标题】:windows.h already included afxv_w32.h - CStringwindows.h 已经包含 afxv_w32.h - CString
【发布时间】:2013-01-07 20:13:27
【问题描述】:

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

“windows.h 已经包含 afxv_w32.h”

这些是我的头文件:

#include stdafx.h

#include shlwapi.h

#include Tlhelp32.h

#include hooks.h

#include stdio.h

#include common1.h

#include SafeLogger.h

#include io.h

#include tinyxml.h

#include winsock.h>

#pragma comment(lib, "Ws2_32.lib")

#include afxinet.h

我没有在堆栈中包含要在此处显示的 gaurds。

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

【问题讨论】:

标签: c++ visual-c++


【解决方案1】:

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

您应该包含 atlstr.h 以获取 CString - 特别是如果您的项目不是基于 MFC 的。

【讨论】:

    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      通过包含,您应该可以在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 
      

      【讨论】:

      • 谢谢。但是这些包含文件遇到了同样的错误
      猜你喜欢
      • 1970-01-01
      • 2016-05-17
      • 1970-01-01
      • 2014-03-10
      • 2016-08-07
      • 1970-01-01
      • 1970-01-01
      • 2018-08-14
      • 1970-01-01
      相关资源
      最近更新 更多