vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Cannot build and debug because the active file is not a C or C++ source file.

Open aranis22 opened this issue 3 years ago • 3 comments

Trying to setup VScode on my new laptop. I'm new to C and coding but I set it up the exact way I did on my other laptop but I got this error: "Cannot build and debug because the active file is not a C or C++ source file."

tasks.json: { "version": "2.0.0", "tasks": [ { "type": "cppbuild", "label": "C/C++: gcc.exe build active file", "command": "C:/mingw64/bin/gcc.exe", "args": [ "-fdiagnostics-color=always", "-g", "${file}", "-o", "${fileDirname}\${fileBasenameNoExtension}.exe", "" ], "options": { "cwd": "C:/mingw64/bin" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true }, "detail": "compiler: C:/mingw64/bin/gcc.exe" } ] }

Anyone got any idea how to approach this? Thanks in advance

aranis22 avatar Aug 06 '22 02:08 aranis22

Maybe that's because the extension name of the file is not c nor cpp.

yvvt0379 avatar Aug 06 '22 03:08 yvvt0379

Maybe that's because the extension name of the file is not c nor cpp.

All files are in the .c format

aranis22 avatar Aug 06 '22 15:08 aranis22

@aranis22 Which file do you have open (that is currently active) when you start build and debug?

Do you have the setting files.associations configured?

Example:

    "files.associations": {
        "*.c": "cpp"
    }

michelleangela avatar Aug 08 '22 18:08 michelleangela

This issue has been closed because it needs more information and has not had recent activity.

github-actions[bot] avatar Oct 08 '22 11:10 github-actions[bot]