混淆函数名称

Mingw confusing function names

本文关键字:函数      更新时间:2023-10-16

我目前正在将一些代码从Visual Studio移植到Mingw。编写组件的人不再可用,我不太熟悉组件的细节。目前我遇到了一个问题,我发现 Mingw 将函数的名称与内部函数混淆了。代码是这样的

 void _mm_prefetch(char const *_A, int _Sel); 
static FORCE_INLINE void sysdep_intrin_prefetch(void *ptr, cardinal_t offset)
{
  _mm_prefetch(REINTERPRET_CAST(const char *, cardinal_to_ptr(ptr_to_cardinal(ptr) + offset)),
           1 /* _MM_HINT_T0 */);
}

错误如下:

||=== Build: Debug x64 in AVS_Wrapper (compiler: MinGW GCC - 2/17/2015) ===|
avs2includewin32aiw.h|247|error: variable or field '__builtin_prefetch' declared void|
avs2includewin32aiw.h|247|error: expected primary-expression before 'char'|
avs2includewin32aiw.h|247|error: expected ')' before 'char'|
avs2includewin32aaw64.h|13|error: expected unqualified-id before '__asm__'|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|

这是我的构建窗口

g++.exe -std=c++11 -DWIN32 -D_DEBUG -D_WINDOWS -D_USRDLL -DAVS_WRAPPER_EXPORTS -DAVS_TARGET_WIN7 -std=c++11 -Iavs2includewin32 -I........mingw64requiredboost_1_57_0 -I. -IC:Usersadmingc3avw -c C:Usersadmingc3avwavw.cpp -o "Win32Debug x64avw.o"
g++.exe -std=c++11 -DWIN32 -D_DEBUG -D_WINDOWS -D_USRDLL -DAVS_WRAPPER_EXPORTS -DAVS_TARGET_WIN7 -std=c++11 -Iavs2includewin32 -I........mingw64requiredboost_1_57_0 -I. -IC:Usersadmingc3avwwrapper -c C:Usersadmingc3avwwrapperAvsSystem.cpp -o "Win32Debug x64wrapperAvsSystem.o"
In file included from C:/mingw64/lib/gcc/x86_64-w64-mingw32/4.8.2/include/x86intrin.h:34:0,
                 from C:/mingw64/x86_64-w64-mingw32/include/winnt.h:1495,
                 from C:/mingw64/x86_64-w64-mingw32/include/minwindef.h:147,
                 from C:/mingw64/x86_64-w64-mingw32/include/windef.h:8,
                 from C:/mingw64/x86_64-w64-mingw32/include/windows.h:69,
                 from C:Usersadmingc3avwwrapperAvsSystem.cpp:1:
avs2includewin32/aiw.h:247:6: error: variable or field '__builtin_prefetch' declared void
 void _mm_prefetch(char const *_A, int _Sel);

显然,从我目前的理解来看,编译器认为 _mm_prefetch功能__builtin_prefetch

我如何告诉编译器它们是不同的。我有什么选择来规避这个问题?

Mingw 将函数的名称与内部函数混淆

它100%有权这样做。 语言规则(2.10p3)规定:

每个以下划线开头的标识符都保留给实现,以用作全局命名空间中的名称。

不要将自己的函数命名为 _mm_prefetch 。 (也就是说,要修复错误,您必须重命名函数。