由于#if,Visual Studio Code 智能感知无法识别头文件的一部分

问题描述

我对 C++ 的 visual studio 代码fmt 库有问题。我让库工作,但我的智能感知在写入时没有显示/填充 fmt/os.h 标头的函数,原因是 os.h 标头中的这些行

我使用 win10 和 mingw g++,底部是我的 tasks.json

#if (FMT_HAS_INCLUDE(<fcntl.h>) || defined(__APPLE__) || \
     defined(__linux__)) &&                              \
    (!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
#  include <fcntl.h>  // for O_RDONLY
#  define FMT_USE_FCNTL 1
#else
#  define FMT_USE_FCNTL 0
#endif

因此,#define FMT_USE_FCNTL 0 会导致智能感知无法识别部分标题(它在第 149 行“注释”部分标题)。我完全是初学者,所以我不知道发生了什么。这是我在构建 fmt 时可以在 cmake 中标记的东西,还是什么?对我来说奇怪的是,一切似乎都很好 fmt::output_file 等工作,但智能感知只是无法识别这些功能。我试过用谷歌搜索这个,但由于我的知识有限,我什至不知道问题出在哪里。

也只是举例,下面这个来自 fmt github 的示例代码运行,但我无法自动填充 output_file 命令,并且智能感知在 output_file 函数显示错误,说命名空间“fmt”没有成员“output_file”。

#include <fmt/os.h>

int main() {
  auto out = fmt::output_file("guide.txt");
  out.print("Don't {}","Panic");
}
{
    "version": "2.0.0","tasks": [
        {
            "type": "shell","label": "build","command": "g++.exe","args": [
                "-Wall","-g","-std=c++2a","${file}","${fileDirname}\\src\\*.cpp","-o","${fileDirname}\\${fileBasenameNoExtension}.exe",// fmt includes and links
                "-I","C:\\Users\\user\\Documents\\1links\\Git\\Git\\cpp_libs\\fmt\\include","-I","C:\\Users\\user\\Documents\\1links\\Git\\Git\\cpp_libs\\fmt\\src","C:\\Users\\user\\Documents\\1links\\Git\\Git\\cpp_libs\\fmt\\Build\\libfmt.a",// library files needed to make the libraries work
            ],"options": {
                "cwd": "C:/MinGW/mingw32/bin"
            },"problemmatcher": [
                "$gcc"
            ],"group": {
                "kind": "build","isDefault": true
            }
        }
    ]
}

这里还有我的 c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Mingw","includePath": [
                "${default}","C:\\Users\\user\\Documents\\1links\\Git\\Git\\cpp_libs\\fmt\\include"
            ],"windowsSdkVersion": "10.0.18362.0","compilerPath": "C:\\MinGW\\bin\\g++.exe","cStandard": "c17","cppStandard": "c++20","intelliSenseMode": "gcc-x86"
        }
    ],"version": 4
}

感谢您抽出宝贵时间。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...