目前我正在开发将在 Raspberry Pi 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++ 导致此兼容性问题的原因。
关于C++ Boost - 在此范围内未声明 __assert_fail,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43676010/