Mingw 容易混淆的函数名
Mingw confusing function names
我目前正致力于将一些代码从 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) ===|
avs2\include\win32\aiw.h|247|error: variable or field '__builtin_prefetch' declared void|
avs2\include\win32\aiw.h|247|error: expected primary-expression before 'char'|
avs2\include\win32\aiw.h|247|error: expected ')' before 'char'|
avs2\include\win32\aaw64.h|13|error: expected unqualified-id before '__asm__'|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
这是我的作品window
g++.exe -std=c++11 -DWIN32 -D_DEBUG -D_WINDOWS -D_USRDLL -DAVS_WRAPPER_EXPORTS -DAVS_TARGET_WIN7 -std=c++11 -Iavs2\include\win32 -I..\..\..\..\mingw64\required\boost_1_57_0 -I. -IC:\Users\admin\gc3\avw -c C:\Users\admin\gc3\avw\avw.cpp -o "Win32\Debug x64\avw.o"
g++.exe -std=c++11 -DWIN32 -D_DEBUG -D_WINDOWS -D_USRDLL -DAVS_WRAPPER_EXPORTS -DAVS_TARGET_WIN7 -std=c++11 -Iavs2\include\win32 -I..\..\..\..\mingw64\required\boost_1_57_0 -I. -IC:\Users\admin\gc3\avw\wrapper -c C:\Users\admin\gc3\avw\wrapper\AvsSystem.cpp -o "Win32\Debug x64\wrapper\AvsSystem.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:\Users\admin\gc3\avw\wrapper\AvsSystem.cpp:1:
avs2\include\win32/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 is confusing the name of a function with an internal function
100% 有权这样做。语言规则 (2.10p3) 说:
Each identifier that begins with an underscore is reserved to the implementation for use as a name in the global namespace.
不要命名您自己的函数 _mm_prefetch
。 (也就是说,要修复错误,您必须重命名该函数。)
我目前正致力于将一些代码从 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) ===|
avs2\include\win32\aiw.h|247|error: variable or field '__builtin_prefetch' declared void|
avs2\include\win32\aiw.h|247|error: expected primary-expression before 'char'|
avs2\include\win32\aiw.h|247|error: expected ')' before 'char'|
avs2\include\win32\aaw64.h|13|error: expected unqualified-id before '__asm__'|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
这是我的作品window
g++.exe -std=c++11 -DWIN32 -D_DEBUG -D_WINDOWS -D_USRDLL -DAVS_WRAPPER_EXPORTS -DAVS_TARGET_WIN7 -std=c++11 -Iavs2\include\win32 -I..\..\..\..\mingw64\required\boost_1_57_0 -I. -IC:\Users\admin\gc3\avw -c C:\Users\admin\gc3\avw\avw.cpp -o "Win32\Debug x64\avw.o"
g++.exe -std=c++11 -DWIN32 -D_DEBUG -D_WINDOWS -D_USRDLL -DAVS_WRAPPER_EXPORTS -DAVS_TARGET_WIN7 -std=c++11 -Iavs2\include\win32 -I..\..\..\..\mingw64\required\boost_1_57_0 -I. -IC:\Users\admin\gc3\avw\wrapper -c C:\Users\admin\gc3\avw\wrapper\AvsSystem.cpp -o "Win32\Debug x64\wrapper\AvsSystem.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:\Users\admin\gc3\avw\wrapper\AvsSystem.cpp:1:
avs2\include\win32/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 is confusing the name of a function with an internal function
100% 有权这样做。语言规则 (2.10p3) 说:
Each identifier that begins with an underscore is reserved to the implementation for use as a name in the global namespace.
不要命名您自己的函数 _mm_prefetch
。 (也就是说,要修复错误,您必须重命名该函数。)