C++ Boost - 无法解析命名空间成员或容器

标签 c++ boost

我正在尝试关注 this Boost 教程无法弄清楚为什么命名空间和容器无法识别。我看了又看都无济于事。任何帮助将不胜感激。

enter image description here


代码如下:

/**
 * Boost Logger Test
 */

#include <boost/log/core/core.hpp>

namespace logging = boost::log;
namespace expr = boost::log::expressions;
namespace sinks = boost::log::sinks;

enum severity_level
{
    normal,
    notification,
    warning,
    error,
    critical
};

void init()
{
    boost::shared_ptr< logging::core > core = logging::core::get();

    logging::add_file_log
            (
                    keywords::file_name = "sample_%N.log",
                    keywords::rotation_size = 10 * 1024 * 1024,
                    keywords::time_based_rotation = sinks::file::rotation_at_time_point(0, 0, 0),
                    keywords::format = "[%TimeStamp%]: %Message%"
            );

    logging::core::get()->set_filter
            (
                    logging::trivial::severity >= logging::trivial::info
            );
}

int main(int argc, char* argv[]) {
    init();
    return 0;
}

最佳答案

你必须

#include <boost/log/utility/setup/file.hpp>
#include <boost/log/trivial.hpp> 

并添加

namespace keywords = boost::log::keywords;

关于C++ Boost - 无法解析命名空间成员或容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29501639/

相关文章:

C++:行为类似于calloc的新调用?

c++ - 就友元而言,为什么别名模板与别名类型模板的处理方式不同?

c++ - 没有上下文类型信息的重载函数

c++ - 需要解释以理解 asio REFERENCE_COUNTED 示例

c++ - boost c++ unordered_map 使用的是什么哈希函数?

c++ - Boost线程泄漏C++

boost - 在 boost 中获取绝对路径

c++ - 在控制台关闭事件上释放内存

c++ - 拖放移动后获取新旧 QStandardItem

c++ - 池内存和 std::forward_list