franneck94 / Vscode-C-Cpp-Runner

🚀 Compile, run and debug single or multiple C/C++ files with ease. 🚀
MIT License
55 stars 14 forks source link

[FEAT] Dedicated Compile Commands for a Source File #135

Open wAuner opened 1 year ago

wAuner commented 1 year ago

Hi,

is it possible to associate a specific compile command per file? I've been using CodeRunner on macOS which lets you define the specific compile command per file. That's absolutely awesome for experiments. I usually keep a directory with snippets/experiments and would it be quite annoying to have to put them all in their separate directory.

franneck94 commented 1 year ago

Can you show me such a command that you can store for a file?

Are you refering to single file compilation?

wAuner commented 1 year ago

Yes I'm referring to single file compilation. In CodeRunner I can set the compile flags per file which is super handy.

CleanShot 2023-10-19 at 14 26 34@2x

franneck94 commented 1 year ago

So a use case would be:

Main1.cc -> Use a Regular Compiler Warnings set Main2.cc -> Compile it with different Compiler Warnings

Without changing the settings.json.

IMHO i dont like having another place of setting any settings for the extension

wAuner commented 1 year ago

yes but of course not only warnings, but the entire command line, including linker flags, include paths etc.

One solution could be to add a dictionary of filename->command mappings in the settings.json.

"C_Cpp_Runner.fileSpecificCompilerArgs": {
    "main.cpp": {
      "cppStandard": "-std=c++2b",
      "linkerArgs": ["$inherited", "-lpcap", "-lfmt"]
    }
  }

So there would be a global or default setting but the user can overwrite or inherit and extend from the global settings.