I keep getting error: "Failed to parse "C:<project folder>\c_cpp_properties.json even with the simplest of projects. I am not sure when this started but I have VSCode, PIO, and all extensions at the latest level.
The problem is that when the json file is created it has invalid comments at the beginning, i.e.:
//
// !!! WARNING !!! AUTO-GENERATED FILE!
// PLEASE DO NOT MODIFY IT AND USE "platformio.ini":
// https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags
//
{
"configurations": [
As you can see, the comments use “//” which is invalid in a json file.
I searched and found previous problems with this json file but nothing like this. Is anyone having this issue and have a fix for it?
The error can be reproduced by deleting the c_cpp_properties.json file, closing, and reopining VSCode/PIO. When VSCode reopens the file is rewritten and does so with the bad comments. Here is the error message:
and here is what the beginning of the json file looks like:
I have uninstalled all parts of the C/C++ Extension pack except C/C++ Intellisense Debugging since it is required by PIO. Also there are two instances of C/C++ Intellisense Debugging listed separately as installed. One is standalone and one as part of the C/C++ Extension pack.
Both extensions I am referring to are by Microsoft. Here is the total list of extensins I have installed where I have highlighted the extension pack showing the twice listed extension (which may be the same one). Except for the extension pack, all the rest (including the bracket colorizer) have been installed for a lot longer than I have seen this error. The only reason I am talking about these extensions is the error message is referring to them. I would uninstall but am not allowed becuase they are required by PIO.
Please remove the C++ Intellisense extension (Austin) as it is known to break Intellisense. Then try deleting the c-cpp-properties.json and see if it is regenerated correctly now.
Where is the template used to generate this file? If I could edit that it would fix the problem short of ununstalling everything and reinstalling. Either that or how to remove the C/C++ extension duplicates without uninstalling PIO
The generation of that file happens in the PlatformIO according to a template .tpl file as described in
That is usually hard-backed into the received PlatformIO executable so you won’t find it as a file on your system. You can PR / create a issue against that repo to have the devs look at it.
Regarding the extensions: I only have C/C++ (Microsoft) and PIO installed. Not the C/C++ extension pack or any other extension, so maybe try that (temporarily deactivate other plugins). But I agree, this can be fixed at the source.
On the other hand, if no comments are allowed, then without that warning, people will again try to modify their c_cpp_properties.json to fix build errors which will never work, because these settings must be done in PlatformIO…
This is a rather new problem so it was introduced recently in something. I can’t be the only one seeing this. I’ll try to eliminate other extensions but I don’t think it will do any good since they have been part of my setup .long before I started seeing this.
Seems it also can’t deal with the situation when there are “(” symbols in the filename.
Looks like it escapes them like this ( which then throws the JSON parser?
Its a problem for STM32 development (Arduino) where the variant files have fairly complex names, including “(” and “)” in them…