【问题标题】:Visual Studio + Boost errorVisual Studio + Boost 错误
【发布时间】:2013-06-25 19:15:30
【问题描述】:

我正在尝试在 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

作者说建筑对他有用。

【问题讨论】:

  • 你真的必须向我们展示 MedLDA.cpp 中的违规代码

标签: c++ visual-studio boost


【解决方案1】:

由于您没有显示任何代码,我们只能猜测。我的猜测是你 #define 某个宏搞砸了 Boost.Math 代码。也许像#define M ......

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

#define M              (397)                 // a period parameter

直接的解决方法是将MedLDA.cpp 中的#include &lt;boost/math/special_functions/gamma.hpp&gt; 行移动到StdAfx.h 之后的第一个包含,这样上述宏就不会影响gamma.hpp 中声明的模板。

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

【讨论】:

  • 添加了该软件的链接。
猜你喜欢
  • 2016-09-17
  • 1970-01-01
  • 2011-02-28
  • 1970-01-01
  • 2016-12-20
  • 2012-12-28
  • 2013-11-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多