1

I'm just testing out a C program in VS Code but there's a green squiggly in my include statement.

enter image description here

This is the warning message at the bottom

enter image description here

How do I fix this?

Here's the code in non-image form

#include <stdio.h>
/*
    this is a comment
*/
main()
{
    char c = 'F';
    printf("%d\n", c - 'A');
}
halfer
  • 19,824
  • 17
  • 99
  • 186
ligary
  • 11
  • 3
  • 1
    Add code here so we can take a look at what ou are doing – rakwaht Sep 08 '17 at 07:58
  • I literally just created a new file called test.c and all the code that's in the file is in the image I linked above. The code compiles and runs fine but I just want to know whats the issue with the editor complaining about my include path – ligary Sep 08 '17 at 08:02
  • One likely reason: don't compile C code as C++. – Lundin Sep 08 '17 at 08:04
  • Related: https://stackoverflow.com/questions/37522462/visual-studio-code-includepath Please, add the code and the error as text inside the question, not as link to images. – Bob__ Sep 08 '17 at 08:15
  • The thing is I'm not compiling it as C++ code. I literally just opened up the file and it's still giving me a warning. I installed the windows sdk but I'm not sure if it's helping. I'm using Bash on Windows to compile and run the C code if that adds anything. – ligary Sep 08 '17 at 08:32
  • Even if you are not compiling your code, VS Code searchs for the `stdio.h` file in the include path... that you haven't yet specified. See this: https://stackoverflow.com/questions/39430277/visual-studio-code-include-file-not-found-in-include-directory-windows-10?rq=1 also. – Bob__ Sep 08 '17 at 09:17

1 Answers1

1

I have another answer to a similar question that explains how to troubleshoot the VSCode error message #include errors detected. Please update your includePath.

A brief summary:

  1. First check your compiler path and IntelliSense mode.
  2. Compare the "C/C++: Log Diagnostics" output to your compiler's built-ins.
  3. Use the "C/C++: Edit Configurations (UI)" if/when you need to set the include path.

See the linked answer for more details.

Scott McPeak
  • 8,803
  • 2
  • 40
  • 79