在此范围内未声明C boost -_______SERT_FAIL

C++ Boost - __assert_fail was not declared in this scope

本文关键字:SERT FAIL boost 范围内 未声明      更新时间:2023-10-16

当前我正在开发将在Raspberry Pi 3上使用的库3。要循环浏览目录中的所有文件,我决定使用boost::filesystem模块。我已经准备了此代码:

#include <boost/foreach.hpp>
#include <boost/filesystem.hpp>
boost::filesystem::path targetDir(some_path);
boost::filesystem::directory_iterator it(targetDir), eod;
BOOST_FOREACH(boost::filesystem::path const& p, std::make_pair(it, eod))
{
    if (boost::filesystem::is_regular_file(p))
    {
        // do smth with file
    }
}

Boost已通过apt-get install libboost1.62-all-dev安装。

不幸的是,在Visual Studio 2017中编译(在远程RPI目标上,G 4.9.2(给了我一堆错误:

__assert_fail was not declared in this scope (path_trails.hpp)
...
__assert_fail was not declared in this scope (path.hpp)
...
__assert_fail was not declared in this scope (shared_ptr.hpp)

我在做什么错?

该问题与Boost没有连接。我上面有#include <Magick++.h>线,这会导致这些输出错误。在评论这一行之后,一切都很好,现在我需要找到为什么Magick 引起了这个合理性问题。

我只是遇到了看起来像同一问题。

奇怪的是,我没有在伸展或克星中看到这个问题,而只有在牛里。您是否使用不是来自Raspbian档案的ImageMagick版本?

无论如何,在我的情况下,Magick 。H最终包括essert.h在名称空间内,当发生这种情况时,它会破坏任何其他试图使用assert.h

的其他代码。

解决方法是重新订购您的包含和/或添加一个明确的assert.h,以便在magick 之前包含assert.h。h