【问题标题】:Boost not recognizing itself as a classBoost不承认自己是一个班级
【发布时间】:2019-06-01 20:26:24
【问题描述】:

boost 给了我“错误 C2653 'boost':不是类或命名空间名称”我试图使用来自 boost 文件系统的 last_write_time() 函数我的用法是 boost::filesystem::last_write_time(boost::filesystem ::path("C:\file.txt")); 我正在使用命名空间 std 并且命令正在主函数中运行 我也没有找到错误标识符,但我很确定那是因为它没有检测到类

#include <iostream>
#include <string>
#include <boost/filesystem.hpp>
#include <boost/filesystem/path.hpp>
#include <iterator>
#include <algorithm>
#include "pch.h"
#include <stdlib.h>
#include <cstdlib>
#include <iostream>
#include <vector>
#include "Windows.h"
#include "psapi.h"
#include <tchar.h>
#include <stdio.h>
#include <strsafe.h>
#include <fileapi.h>

【问题讨论】:

  • 嗨,你能显示你正在尝试编译的实际代码吗?
  • 我试图编译的代码是:time_t tim = boost::filesystem::last_write_time(boost::filesystem::path("C:\file.txt"));

标签: visual-c++ boost


【解决方案1】:

假设pch.h 是预编译的头文件,#include "pch.h" 应该是源文件中第一个非注释行。编译器会忽略它上面的所有内容。

【讨论】:

  • 如果我尝试使用它们,我已经关闭了预编译头文件 boost 不会工作
  • 幽默一下。如果将#include "pch.h" 移到顶部,是否仍然出现这些错误,所以它是第一行?
  • 我收到一个较早的错误,其中 Visual c++ 无法打开文件系统库“致命错误 LNK1104:无法打开文件 'libboost_filesystem-vc140-mt-1_62.lib'”
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-25
  • 2019-07-05
相关资源
最近更新 更多