如何修复已定义的类模板?

发布于 2024-08-23 07:56:47 字数 599 浏览 3 评论 0原文

我正在将 ZipArchive 库实现到我的项目中,我与它斗争了一个多小时,使其正确设置以阻止所有链接器错误。但现在我仍然剩下这个问题,我不确定修复它的最佳方法,需要一些帮助。

C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxtls_.h(199) : error C2953: 'CThreadLocal' : class template has already been defined
c:\dev-mms\hl2sdk-ob-valve\public\tier0/threadtools.h(283) : see declaration of 'CThreadLocal'
C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxtls_.h(202) : warning C4005: 'THREAD_LOCAL' : macro redefinition
c:\dev-mms\hl2sdk-ob-valve\public\tier0/threadtools.h(71) : see previous definition of 'THREAD_LOCAL'

I am implementing ZipArchive library into my project, and I fought with it for over an hour getting it setup right to stop all the linker errors. But now I still have this left over and I am not sure of the best approach to fix it, could use some help.

C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxtls_.h(199) : error C2953: 'CThreadLocal' : class template has already been defined
c:\dev-mms\hl2sdk-ob-valve\public\tier0/threadtools.h(283) : see declaration of 'CThreadLocal'
C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxtls_.h(202) : warning C4005: 'THREAD_LOCAL' : macro redefinition
c:\dev-mms\hl2sdk-ob-valve\public\tier0/threadtools.h(71) : see previous definition of 'THREAD_LOCAL'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

來不及說愛妳 2024-08-30 07:56:48

C++ 模板提示:

  • 所有内容都必须位于头文件 (.h) 中
  • 才能解决重新定义问题,只需将代码放入:
#ifndef __MY_CODE_eg
#define __MY_CODE_eg

      // your code
      // here.

#endif

C++ Templates hints:

  • EVERYTHING must be in the header file ( .h)
  • to solve redefinition just put your code into:
#ifndef __MY_CODE_eg
#define __MY_CODE_eg

      // your code
      // here.

#endif
以往的大感动 2024-08-30 07:56:48

MS 的 ATL/MFC 标头和 HL2 SDK 都包含类模板 CThreadLocal

如果您按照正确的顺序包含这些标头,即首先包含 ATL/MFC 标头(或包含它们的标头),然后包含 HL2 SDK 标头,则 HL2 SDK 应该通过 #ifndef __AFXTLS_H__

Both MS' ATL/MFC headers and the HL2 SDK contain a class template CThreadLocal.

If you'd include those in the right order, i.e. ATL/MFC headers first (or the headers which include them), then the HL2 SDK headers, the HL2 SDK should handle that problem via an #ifndef __AFXTLS_H__.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文