vscode no such file or directory

I’m currently using MSVC.

This is my Directory Structure

ProjectDir
|_.vscode
  |_ c_cpp_properties.json
  |_ tasks.json
|_ Public
  |_ Main.cpp
  |_ DirectoryParser.h
|_ Private
  |_ DirectoryParser.cpp

This is my DirectoryParser

// Public/DirectoryParser.h
class DirectoryParser
{
public:
    DirectoryParser();
};

// Private/DirectoryParser.cpp
#include "DirectoryParser.h"

DirectoryParser::DirectoryParser()
{
}

And this is my Json

// .vscode/tasks.json
{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: cl.exe build active file",
            "command": "cl.exe",
            "args": [
                "/Zi",
                "/EHsc",
                "/nologo",
                "/Fe${workspaceFolder}\\${fileBasenameNoExtension}.exe",
                "/Fd:${workspaceFolder}\\obj\\debug\\vc140.pdb",
                "/Fo:${workspaceFolder}\\obj\\debug\\",
                "${workspaceFolder}\\public\\*.cpp",
                "${workspaceFolder}\\private\\*.cpp",
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$msCompile"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}
// c_cpp_properties.json
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.22000.0",
            "compilerPath": "cl.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-msvc-x64"
        }
    ],
    "version": 4
}

I think include would work if I add IncludePath at c_cpp_properties.json.

But DirectoryParser.cpp has error ‘No such file or directory.’

If I include like this

#include "./../Public/DirectoryParser.h

works right.

Doesn’t that IncludePath make defaut root?

  • 1

    Doesn’t that IncludePath make defaut root? IncludePath has nothing to do with building. For building you need to also set the include directories in the args

    – 




Leave a Comment