开发者

std::min is being redefined, but how?

Do streflop or boost libraries change the definition of std::min?

I have a project that compiles fine with g++/make UNTIL I merge it with the CMake build of another project (using add_directory). Suddenly I get:

no matching function for call to min(double&,float)

The line number it claims the error is on is wrong (it's pointing to the last line of the source file) but I'm going to assume the relevant code is this:

first = std::min (first, key.mTime);

Where first is declared as a double.

The 'parent' project (Spring RTS) uses boost and streflop but even after replacing all includes for <math.h> with "streflop_cond.h" in the child project (assimp) the problem remains.

Maybe some compiler flags are responsible, I'm not sure. An theories would be appreci开发者_运维知识库ated. The source for both projects are available online.

I've spent nearly 7 hours on this now and I don't seem any closer to a solution.

The full error and build flags is:

    [ 61%] Building CXX object rts/lib/assimp/code/CMakeFiles/assimp.dir/ScenePreprocessor.cpp.o
cd /mnt/work/workspace/spring-patch-git/linux/build/rts/lib/assimp/code && /usr/bin/g++   -Dassimp_EXPORTS -DSYNCCHECK -DNO_AVI -DSPRING_DATADIR=\"/usr/local/share/games/spring\" -DSTREFLOP_SSE -DASSIMP_BUILD_DLL_EXPORT -msse -mfpmath=sse -fsingle-precision-constant -frounding-math -mieee-fp -pipe -fno-strict-aliasing -fvisibility=hidden -fvisibility-inlines-hidden -pthread  -O0 -Wall -Wno-sign-compare -DDEBUG -D_DEBUG -DNO_CATCH_EXCEPTIONS -gstabs -fPIC -I/mnt/work/workspace/spring-patch-git/spring/rts/System -I/mnt/work/workspace/spring-patch-git/spring/rts/lib/lua/include -I/mnt/work/workspace/spring-patch-git/spring/rts/lib/streflop -I/usr/include/SDL -I/usr/include/boost-1_39 -I/mnt/work/workspace/spring-patch-git/spring/rts -I/usr/include/AL -I/usr/include/freetype2 -I/mnt/work/workspace/spring-patch-git/spring/rts/lib/assimp/include -I/mnt/work/workspace/spring-patch-git/spring/rts/lib/assimp/../streflop   -o CMakeFiles/assimp.dir/ScenePreprocessor.cpp.o -c /mnt/work/workspace/spring-patch-git/spring/rts/lib/assimp/code/ScenePreprocessor.cpp
/mnt/work/workspace/spring-patch-git/spring/rts/lib/assimp/code/ScenePreprocessor.cpp: In member function void Assimp::ScenePreprocessor::ProcessAnimation(aiAnimation*):
/mnt/work/workspace/spring-patch-git/spring/rts/lib/assimp/code/ScenePreprocessor.cpp:280: error: no matching function for call to min(double&, float)
make[2]: *** [rts/lib/assimp/code/CMakeFiles/assimp.dir/ScenePreprocessor.cpp.o] Error 1


Try

std::min<double>(first, key.mTime);

The two arguments seem to have different types so the compiler can't resolve the template argument to std::min

EDIT3: I actually took a look at the assimp library and from your error message, it's line 280 of ScenePreprocessor.cpp that's the cause of the problems:

anim->mDuration = last - std::min( first, 0. );

There's nothing wrong with this line however, first is declared as a double and 0. means a zero double literal.

I would guess that the problem lies in the STREFLOP library, it seems like it's incorrectly interpreting 0. as a float literal.


Could this error be related to min() being a template and expecting parameters to be of the same type? The error message suggests you are putting a double and a float into it.
While this doesn't answer your question if min() is redefined, it may help with the compiling problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜