VS Code: command-line error:missing source file name

Viewed 4089

This is picture of my screen: this is a picture of my screen.This error shows up when I enter #include <stdio.h>to begin my program. I'm not sure how to fix this. Every file in Visual Studio Code is now having this issue.

I use gcc. gcc -o outputname filename.c and using C/C++ IntelliSense, debugging, and code browsing extension by Microsoft.

4 Answers

As you didn't explain the question well. I think that there is a macro in the build options that is not defined so it gets inserted into the build command as a blank string. Does your project use some macros in the build options maybe something for 55x CSL directory?

If so make sure to define these macros on the macro tab of the build options dialog.

Various things may contribute to this error:

  • unclosed quotes in preprocessor definitions, macros or even c_cpp_properties.json
  • file encoding
  • the VS Code cpp extension

It has come and gone in my c/c++ development, and I don't know if anything specific I've done fixes it or if just restarting VS Code is the solution.

Most recently, I

  1. changed the encoding of all files from UTF-8 to ANSI (in case there were any hidden unicode characters in the file, which happens with copy & paste sometimes)
  2. restarted VS Code
  3. it then complained that the c/c++ extension wasn't installed (it was?) and so I installed it again, and the error is gone.

I had the same issue. I just uninstalled and reinstalled the c/c++ extension and it was back to normal

I ran into the same problem this morning. IntelliSense was at fault. Only solution I quickly had found for me was to hard-delete C++ IntelliSense extension. Plain uninstall did not help.

You can remove IntelliSense Extension this way:

  • close all instances of Visual Studio Code,
  • navigate to folder %USERPROFILE%\.vscode\extensions
  • delete a folder/folders (incl. subfolders) ms-vscode.cpptools*
  • start Visual Studio Code again and install fresh IntelliSense extension.

NOTE: you may lose your IntelliSense custom settings!

Related