Vscode-C-Cpp-Runner icon indicating copy to clipboard operation
Vscode-C-Cpp-Runner copied to clipboard

[FEAT] Dedicated Compile Commands for a Source File

Open wAuner opened this issue 8 months ago • 4 comments

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.

wAuner avatar Oct 19 '23 11:10 wAuner

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

Are you refering to single file compilation?

franneck94 avatar Oct 19 '23 11:10 franneck94

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

wAuner avatar Oct 19 '23 12:10 wAuner

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

franneck94 avatar Oct 20 '23 06:10 franneck94

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.

wAuner avatar Oct 20 '23 07:10 wAuner