#Help with including header files with vscode debugging

20 messages · Page 1 of 1 (latest)

hardy salmon
#

how can I include my header files to the tasks.json file?
I'm trying to add the header files that are in the "includes" folder from the directory the file was built in...

{
  "tasks": [
    {
      "type": "cppbuild",
      "label": "C/C++: g++.exe build active file",
      "command": "C:\\msys64\\ucrt64\\bin\\g++.exe",
      "args": [
        "-fdiagnostics-color=always",
        "-g",
        "${file}",
        // "${fileDirname}/includes/",
        // "${fileDirname}/includes/*.cpp",
        // "${fileDirname}\\includes\\",
        // "${fileDirname}\\includes\\*.cpp",
        "-o",
        "${fileDirname}\\${fileBasenameNoExtension}.exe"
      ],
      "options": {
        "cwd": "${fileDirname}"
      },
      "problemMatcher": ["$gcc"],
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "detail": "Task generated by Debugger."
    }
  ],
  "version": "2.0.0"
}

solemn flowerBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

floral hill
hardy salmon
#

so maybe there's something i'm not understanding?

#

I've included a picture of what my directory looks like, if I use the visual studio debugger for a file like "while_user_gullible.cpp" it works, but when I start trying to use headers, like for the file "header_test.cpp" it wont work because the compiler doesn't know where the header files exist...

If I compile with G++:
>G++ header_test.cpp icludes/log.cpp
I would have to add the files into the command.
So how can I add these files in a way that the "Build active file" command/Debugger can know where the references are for the active file?

hardy salmon
#

🥺 maybe this just isn’t possible?

floral hill
# hardy salmon I've included a picture of what my directory looks like, if I use the visual stu...

I don't understand your problem.
I suppose you want to include some folder of yours to the include list, so that you can do #include "../header_test/includes/log.h or whatever you want to do there.

Also in your command there a typo in includes, you wrote icludes.

Is this question purely about VS Code? Also why would you even want to use VS Code's build tool rather than having a Makefile, or even better a CMake project?
If it is purely for VS Code, then probably #tooling is a better place to check

hardy salmon
#

My original use case for the Visual Studio Debugger was for practicing purposes, I wanted to split my workspace up into sub directories of my projects and be able to run the debugger isolated to the folder the file I selected to debug is in... if that makes sense?

floral hill
# hardy salmon hmmm so that's what I meant when I originally replied, "Maybe there's something ...

Visual Studio Code is just a text editor. It needs a specific tasks.json file that looks a specific way (idk, never did it myself) to know how you can run code.

A Makefile is a build system, i.e. it's basically a shortcut for writing the manual command.

CMake is a meta-build system, i.e. it's a shortcut for writing a build system, i.e. instead of needing to write the Makefile you can just let CMake generate it for you.
The advantage with using CMake over a Makefile is that CMake can generate all kinds of build files. A very popular build system besides Makefiles is Ninja, or Visual Studio (Visual Studio is NOT the same as a VS Code) solutions when you're on Windows

hardy salmon
#

Nah I'm not a student, and i'm not new to programming. Just new to the compiling side of programming

#

I just wanted to make a directory of my practice files so I can easily reference them while learning

floral hill
# hardy salmon Nah I'm not a student, and i'm not new to programming. Just new to the compiling...

Was asking because I personally am using CLion, which has a nice integration for CMake. Problem is that CLion is not free, unless you're a student in which case the entire JetBrains product range is free.
However some similar CMake plugin probably exists for VS Code.

Here, you can check page 47 (the CMake part starts at page 51) if you want some more information on building/CMake. Also the slides in general are pretty good if you're still looking for resources to learn from

hardy salmon
solemn flowerBOT
#

@hardy salmon Has your question been resolved? If so, type !solved :)

hardy salmon
#

not really no

#

the questin is still open

floral hill
# hardy salmon the questin is still open

It's an automated bot response if the last message has been from OP and contained a "thanks" or smth comparable I believe.
You can just ignore it if it doesn't apply.

hardy salmon
#

that's funny, I was wondering what triggered that lmao, It was also a good oppurtunity to bump the discussion lmao