"name followed by '::' must be a class or namespace name" 发布模式错误但调试模式错误

"name followed by '::' must be a class or namespace name" error in release mode but not debug mode

C++,Visual Studio 2019

我在发布模式下不断收到此错误,但在使用“文件系统”和“计时”库的行的调试模式下却没有。我认为这个问题可能与头文件在发布模式下的链接方式有关。

下面是我的代码的相关片段(省略号表示省略的代码)。错误的红色下划线分别在“chrono”和“filesystem”下。

#include <iostream>
#include <vector>
#include <fstream>
#include <numeric>
#include <string>
#include <algorithm>
#include <ctime>
#include <iterator>
#include <filesystem>
#include <cmath>
using namespace std; 

...

int main() {
    auto startTime = chrono::steady_clock::now();  // ERROR HERE

    ...

    for (auto& entry : filesystem::directory_iterator(AbsPath + PTS_ByIndustry_Path)) { // ERROR HERE
        if (find(TS_ToIncludeNums.begin(), TS_ToIncludeNums.end(), i) != TS_ToIncludeNums.end()) {
            string p = entry.path().u8string();
            PTS_ToInclude.push_back(p);
        }
        i++;
    }

    ...
}

您似乎没有导入 chrono header.

#include <chrono>

已修复!在项目属性中,我将调试模式的语言标准更改为 C++17,而不是发布模式。

截图: .