boost::program_options 造成缓冲区溢出

发布于 2024-09-06 05:33:51 字数 770 浏览 1 评论 0原文

我在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

会发光的星星闪亮亮i 2024-09-13 05:33:51

它在 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.

断爱 2024-09-13 05:33:51

我发现我链接到 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文