我想,當適當地包括交叉編譯一段代碼,它使用float.h時設置一些FPU大小。FLOAT.H未找到或使用的MinGW-W64
代碼的特定部分,需要它是:
#ifdef SINGLE
_control87(_PC_24, _MCW_PC); /* Set FPU control word for single precision. */
#else /* not SINGLE */
_control87(_PC_53, _MCW_PC); /* Set FPU control word for double precision. */
#endif /* not SINGLE */
當我編譯,但是,我得到的錯誤
/home/rcrozier/src/xfemm-hg/mfemm/../cfemm/fmesher/triangle.c:4922:14: error: '_PC_53' undeclared (first use in this function)
_control87(_PC_53, _MCW_PC); /* Set FPU control word for double precision. */
另一個人解釋了什麼似乎是更同樣的問題細節here。在(較舊的)線程here中描述了一個非常類似的問題。在相關的情況下,我正在使用mingw-w64
,但通過M Cross Environment
在這種情況下,float.h
問題到底是什麼情況,是否有解決方法?
編輯:從gcc的詳細輸出
Using built-in specs.
COLLECT_GCC=/opt/mxe/usr/bin/x86_64-w64-mingw32.shared-gcc
Target: x86_64-w64-mingw32.shared
Configured with: /opt/mxe/tmp-gcc-x86_64-w64-mingw32.shared/gcc-4.9.4/configure --target=x86_64-w64-mingw32.shared --build=x86_64-unknown-linux-gnu --prefix=/opt/mxe/usr --libdir=/opt/mxe/usr/lib --enable-languages=c,c++,objc,fortran --enable-version-specific-runtime-libs --with-gcc --with-gnu-ld --with-gnu-as --disable-nls --disable-multilib --without-x --disable-win32-registry --enable-threads=win32 --enable-libgomp --with-gmp=/opt/mxe/usr/x86_64-unknown-linux-gnu --with-isl=/opt/mxe/usr/x86_64-unknown-linux-gnu --with-mpc=/opt/mxe/usr/x86_64-unknown-linux-gnu --with-mpfr=/opt/mxe/usr/x86_64-unknown-linux-gnu --with-cloog=/opt/mxe/usr/x86_64-unknown-linux-gnu --with-as=/opt/mxe/usr/bin/x86_64-w64-mingw32.shared-as --with-ld=/opt/mxe/usr/bin/x86_64-w64-mingw32.shared-ld --with-nm=/opt/mxe/usr/bin/x86_64-w64-mingw32.shared-nm
Thread model: win32
gcc version 4.9.4 (GCC)
COLLECT_GCC_OPTIONS='-c' '-I' '../cfemm/fmesher' '-I' '../cfemm/libfemm' '-I' '../cfemm/libfemm/liblua' '-I' '/usr/local/MATLAB/R2015a/extern/include' '-I' '/usr/local/MATLAB/R2015a/simulink/include' '-D' 'MATLAB_MEX_FILE' '-std=c99' '-D' '_GNU_SOURCE' '-fexceptions' '-fPIC' '-fno-omit-frame-pointer' '-pthread' '-v' '-fpermissive' '-D' 'CPU86' '-D' 'MX_COMPAT_32' '-O' '-D' 'NDEBUG' '-o' '/home/rcrozier/src/xfemm-hg/mfemm/../cfemm/fmesher/triangle.o' '-mtune=generic' '-march=x86-64'
/opt/mxe/usr/libexec/gcc/x86_64-w64-mingw32.shared/4.9.4/cc1 -quiet -v -I ../cfemm/fmesher -I ../cfemm/libfemm -I ../cfemm/libfemm/liblua -I /usr/local/MATLAB/R2015a/extern/include -I /usr/local/MATLAB/R2015a/simulink/include -D_REENTRANT -U_REENTRANT -D MATLAB_MEX_FILE -D _GNU_SOURCE -D CPU86 -D MX_COMPAT_32 -D NDEBUG /home/rcrozier/src/xfemm-hg/mfemm/../cfemm/fmesher/triangle.c -quiet -dumpbase triangle.c -mtune=generic -march=x86-64 -auxbase-strip /home/rcrozier/src/xfemm-hg/mfemm/../cfemm/fmesher/triangle.o -O -std=c99 -version -fexceptions -fPIC -fno-omit-frame-pointer -fpermissive -o /tmp/ccMkwwWD.s
cc1: warning: command line option '-fpermissive' is valid for C++/ObjC++ but not for C
GNU C (GCC) version 4.9.4 (x86_64-w64-mingw32.shared)
compiled by GNU C version 4.8.4, GMP version 6.1.1, MPFR version 3.1.4, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/opt/mxe/usr/lib/gcc/x86_64-w64-mingw32.shared/4.9.4/../../../../x86_64-w64-mingw32.shared/sys-include"
#include "..." search starts here:
#include <...> search starts here:
../cfemm/fmesher
../cfemm/libfemm
../cfemm/libfemm/liblua
/usr/local/MATLAB/R2015a/extern/include
/usr/local/MATLAB/R2015a/simulink/include
/opt/mxe/usr/lib/gcc/x86_64-w64-mingw32.shared/4.9.4/include
/opt/mxe/usr/lib/gcc/x86_64-w64-mingw32.shared/4.9.4/include-fixed
/opt/mxe/usr/lib/gcc/x86_64-w64-mingw32.shared/4.9.4/../../../../x86_64-w64-mingw32.shared/include
End of search list.
編輯:更多信息
我也得到了同樣的結果,如果我使用完整的目錄路徑mingw-w64
float.h
像這樣:
//#include <float.h>
#include "/opt/mxe/usr/x86_64-w64-mingw32.static/include/float.h"
編輯更多信息的代碼結構
要提供一些進一步的信息,我實際上正在編譯C庫(頭文件和C文件),其中我使用的函數聲明包括使用extern C
。從頭文件中的實際聲明如下:
#ifdef __cplusplus
extern "C" {
#endif
#ifdef ANSI_DECLARATORS
int triangulate(char *, struct triangulateio *, struct triangulateio *,
struct triangulateio *, int (*TriMessage)(const char * format, ...));
void trifree(VOID *memptr);
#else /* not ANSI_DECLARATORS */
int triangulate();
void trifree();
#endif /* not ANSI_DECLARATORS */
#ifdef __cplusplus
}
#endif
我使用的實際庫Triangle。該float.h時包括在triangle.c,看起來像這樣:
#ifdef CPU86
//#include <float.h>
#include "/opt/mxe/usr/x86_64-w64-mingw32.static/include/float.h"
#endif /* CPU86 */
#ifdef LINUX
#include <fpu_control.h>
#endif /* LINUX */
你在哪裏編譯時定義CPU86
或LINUX
。對於交叉構建,我正在定義CPU86
。
我理解正確嗎?你期望float.h來定義_PC_53的東西? **爲什麼?** –
這是我的谷歌搜索表明,不是嗎?你知道真正的問題嗎? – crobar
否:http://en.cppreference.com/w/cpp/header/cfloat真正的問題很難說,但可能是一個配置問題。 –