编译以前项目更改在x64下面时报错:函数“PVOID GetCurrentFiber(void)”已有主体

win32下面编译成功,但是x64报错

1>GetWord.c

1>md5.c 这两个文件无法编译

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h(24125,1): error C2084: 函数"PVOID GetCurrentFiber(void)"已有主体

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h(8092,16): message : 参见"GetCurrentFiber"的前一个定义

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h(24136,1): error C2084: 函数"PVOID GetFiberData(void)"已有主体

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h(8091,16): message : 参见"GetFiberData"的前一个定义

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h(24220,24): error C2084: 函数"_TEB *NtCurrentTeb(void)"已有主体

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h(24115,1): message : 参见"NtCurrentTeb"的前一个定义

定位头文件,发现可能是同时定义了_M_AMD64和_M_IX86,导致函数重复定义

cpp 复制代码
//C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h (24125,1): error C2084: 函数"PVOID GetCurrentFiber(void)"已有主体
#if defined(_M_AMD64) && !defined(_M_ARM64EC) && !defined(__midl)

__forceinline
struct _TEB *NtCurrentTeb (    VOID    ){    return (struct _TEB *)__readgsqword(FIELD_OFFSET(NT_TIB, Self));}

__forceinline
PVOID GetCurrentFiber (    VOID    ){    return (PVOID)__readgsqword(FIELD_OFFSET(NT_TIB, FiberData));}

__forceinline
PVOID GetFiberData (    VOID    ){    return *(PVOID *)GetCurrentFiber();}

#endif // _M_AMD64 && !defined(__midl)

//1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h(8092,16): message : 参见"GetCurrentFiber"的前一个定义

#if !defined(MIDL_PASS) && defined(_M_IX86)
...
#if !defined(_MANAGED)
__inline PVOID GetFiberData( void )    { return *(PVOID *) (ULONG_PTR) __readfsdword (0x10);}
__inline PVOID GetCurrentFiber( void ) { return (PVOID) (ULONG_PTR) __readfsdword (0x10);}
#endif // !defined(_MANAGED)
#endif // !defined(MIDL_PASS) && defined(_M_IX86)

//1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h(24220,24): error C2084: 函数"_TEB *NtCurrentTeb(void)"已有主体
#if defined(_M_IX86) && !defined(MIDL_PASS)

#define PcTeb 0x18

#if !defined(_M_CEE_PURE)

__inline struct _TEB * NtCurrentTeb( void ) { return (struct _TEB *) (ULONG_PTR) __readfsdword (PcTeb); }

#endif // !defined(_M_CEE_PURE)

#endif // defined(_M_IX86) && !defined(MIDL_PASS)

_M_IX86 : 32bit处理器

_M_AMD64 : 64bit AMD处理器 (VC2008以前)

查询GetWord.c的头文件GetWord.h

cpp 复制代码
#ifndef __getword__
#define __getword__

    #ifdef __cplusplus
    extern "C" {
    #endif

	#include "OSHeaders.h"
	
    char* GetWord( char* toWordPtr, char* fromStrPtr, SInt32 limit );
    char* GetQuotedWord( char* toWordPtr, char* fromStrPtr, SInt32 limit );

    #ifdef __cplusplus
    }   
    #endif

#endif

OSHeaders.h包含Win32header.h定义

#include "Win32header.h" 其中定义了如下内容

cpp 复制代码
#ifndef _X86_
    #define _X86_ 1
#endif

/* Pro4 compilers should automatically define this to appropriate value */
#ifndef _M_IX86
    #define _M_IX86 500
#endif

造成冲突,引发一些函数定义多次包含。

解决方法:

就是把这些定义删除掉。

相关推荐
小汉堡编程3 小时前
数据结构——vector数组c++(超详细)
数据结构·c++
tan180°8 小时前
MySQL表的操作(3)
linux·数据库·c++·vscode·后端·mysql
彭祥.9 小时前
Jetson边缘计算主板:Ubuntu 环境配置 CUDA 与 cudNN 推理环境 + OpenCV 与 C++ 进行目标分类
c++·opencv·分类
lzb_kkk9 小时前
【C++】C++四种类型转换操作符详解
开发语言·c++·windows·1024程序员节
胖大和尚11 小时前
clang 编译器怎么查看在编译过程中做了哪些优化
c++·clang
钱彬 (Qian Bin)12 小时前
一文掌握Qt Quick数字图像处理项目开发(基于Qt 6.9 C++和QML,代码开源)
c++·开源·qml·qt quick·qt6.9·数字图像处理项目·美观界面
双叶83613 小时前
(C++)学生管理系统(正式版)(map数组的应用)(string应用)(引用)(文件储存的应用)(C++教学)(C++项目)
c语言·开发语言·数据结构·c++
源代码•宸13 小时前
C++高频知识点(二)
开发语言·c++·经验分享
jyan_敬言15 小时前
【C++】string类(二)相关接口介绍及其使用
android·开发语言·c++·青少年编程·visual studio
liulilittle15 小时前
SNIProxy 轻量级匿名CDN代理架构与实现
开发语言·网络·c++·网关·架构·cdn·通信