1

我正在尝试在 Visual Studio C++ Express 2010 中使用 Boost 构建解决方案并收到以下错误:

1>------ Build started: Project: MEDsLDAc, Configuration: Release Win32 ------
1>  MedLDA.cpp
1>D:\_download\boost_1_53_0\boost/math/constants/calculate_constants.hpp(152): error C2988: unrecognizable template declaration/definition
1>D:\_download\boost_1_53_0\boost/math/constants/calculate_constants.hpp(152): error C2059: syntax error : 'constant'
1>D:\_download\boost_1_53_0\boost/math/constants/calculate_constants.hpp(153): error C2143: syntax error : missing ')' before '>'
1>D:\_download\boost_1_53_0\boost/math/constants/calculate_constants.hpp(184): error C2244: 'boost::math::constants::detail::constant_euler<T>::compute' : unable to match function definition to an existing declaration
1>          definition
1>          'T boost::math::constants::detail::constant_euler<T>::compute(void)'
1>          existing declarations
1>          'T boost::math::constants::detail::constant_euler<T>::compute(void)'
1>MedLDA.cpp(385): warning C4244: 'initializing' : conversion from 'double' to 'long', possible loss of data
1>MedLDA.cpp(426): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\string.h(105) : see declaration of 'strcpy'
1>MedLDA.cpp(485): warning C4244: 'initializing' : conversion from 'double' to 'long', possible loss of data
1>MedLDA.cpp(608): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\string.h(105) : see declaration of 'strcpy'
1>MedLDA.cpp(609): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\string.h(105) : see declaration of 'strcpy'
1>MedLDA.cpp(636): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\string.h(105) : see declaration of 'strcpy'
1>MedLDA.cpp(730): warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
1>MedLDA.cpp(963): warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>MedLDA.cpp(1150): warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
1>MedLDA.cpp(1241): warning C4244: 'initializing' : conversion from 'double' to 'long', possible loss of data
1>MedLDA.cpp(1296): warning C4244: 'initializing' : conversion from 'double' to 'long', possible loss of data
========== Build: 0 succeeded, 1 failed, 2 up-to-date, 0 skipped ==========

如何解决?

更新:该软件是 MedLDAc,可在此处获得: http ://www.ml-thu.net/~jun/medlda.shtml

作者说建筑对他有用。

4

1 回答 1

4

由于您没有显示任何代码,我们只能猜测。我的猜测是你#define的一些宏会弄乱Boost.Math代码。也许像#define M ......

更新:事实证明我的猜测是正确的。看看MedLDAc/MEDsLDAc/cokus.h file

#define M              (397)                 // a period parameter

直接的解决方法是将#include <boost/math/special_functions/gamma.hpp>line移入MedLDA.cpp成为第一个包含在 之后StdAfx.h的,以便上述宏不会影响在 中声明的模板gamma.hpp

PS 定义一个字母的宏是一个非常非常糟糕的主意。

于 2013-06-26T09:29:48.653 回答