I have problem with visual studio code and fmt library for c++. I get the library to work but my intellisense does not show/fill fmt/os.h header's functions when writing, And the reason for that is these lines in the os.h header
I use win10 and mingw g++ and at the bottom is my 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
So #define FMT_USE_FCNTL 0 causes parts of the header to be not recognized by the intellisense (it "comments" off parts of the header at the line 149). I am total beginner in this, so I have no idea what is going on. Is this something I could flag in cmake when building fmt, or what? Weird thing for me is that everything seems to work great fmt::output_file etc. works, but intellisense just does not recognize those functions. I have tried googling this, but since my knowledge is limited I don't even know where the problem could be.
Also just for example, this example code from fmt github below runs, but I can't auto fill the output_file command, and intellisense shows error on the output_file function saying that namespace "fmt" does not have member "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
}
}
]
}
Also here is my 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
}
Thank you for your time.
question from:
https://stackoverflow.com/questions/65541201/visual-studio-code-intellisense-does-not-recognize-parts-of-header-files-because