boost::program_options 造成缓冲区溢出
我在使用 boost:program_options 这个简单的程序时遇到问题
,该程序是从 boosts 的文档复制粘贴的:
#include <boost/program_options.hpp>
int main( int argc, char** argv )
{
namespace po = boost::program_options;
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("compression", po::value<int>(), "set compression level")
;
return 0;
}
因缓冲区溢出而失败。
我已激活“缓冲区安全开关”,当我运行它时,当我跨过 desc.add_options()...
行时,我收到“未知异常 (0xc0000409)”,
我使用 Visual Studio 2005 年并提升 1.43.0。
顺便说一下,如果我停用开关,它确实会运行,但我觉得这样做不太舒服……除非可以在本地停用它。
那么你有办法解决这个问题吗?
编辑 我发现了问题 我正在链接 libboost_program_options-vc80-mt.lib 这不是一个好的库。
I have a problem using boost:program_options
this simple program, copy-pasted from boosts' documentation :
#include <boost/program_options.hpp>
int main( int argc, char** argv )
{
namespace po = boost::program_options;
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("compression", po::value<int>(), "set compression level")
;
return 0;
}
fails with a buffer overflow.
I have activated the "buffer security switch", and when I run it I get an "unknown exception (0xc0000409)" when I step over the line desc.add_options()...
I use Visual Studio 2005 and boost 1.43.0.
By the way it does run if I deactivate the switch but I don't feel comfortable doing so... unless it's possible to deactivate it locally.
So do you have a solution to this problem?
EDIT
I found the problem
I was linking against libboost_program_options-vc80-mt.lib which wasn't the good library.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它在 2010 年运行。本来想在 2005 年尝试,但意识到我没有在那个环境中编译 1.43。
It works in 2010. Was about to try in 2005 but realized I don't have 1.43 compiled in that environment.
我发现我链接到 libboost_program_options-vc80-mt.lib 的问题,这不是一个好的库,因为我将运行时库更改为多线程 DLL。
I found the problem I was linking against libboost_program_options-vc80-mt.lib which wasn't the good library since I changed the runtime library to Multithread DLL.