I have had this same issue with C/C++ files, specifically over an ssh connection. What fixed it for me was going to C/C++: Select IntelliSense Configuration
in the command palette and changing it to target gcc on the remote server (substitute gcc for your compiler). It was previously trying to use a C compiler on my local machine.
I figured this out from this article which is specifically about TypeScript, but it lead me to the source of the problem.