PlatformIO Community

Failed to parse c_cpp_properties.json

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?

Screenshot of where that error occurs?

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:
image
and here is what the beginning of the json file looks like:
image

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.

You have a special extension that handles JSON files? The color scheme and highlighting is very different from what I have

grafik

Where it’s not marked as an error (but as a warning)

What other extensions do you have installed and in which version?

Are we talking about “C/C++” by Microsoft or “C++ Intellisense” by austin here?

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.

image

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.

I did that and the problem remains.

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…

1 Like

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.

How/where do I report this problem?

BTW, I edited the tpl file and it fixed the problem

1 Like

Max linked to the repository containing the file above: https://github.com/platformio/platformio-core/blob/develop/platformio/ide/tpls/vscode/.vscode/c_cpp_properties.json.tpl

You could submit a PR against this file with the suggested changes, or open an issue.

I’m also having this issue - after upgrading to the latest. Fixed in the meantime by editing the template file.

I have generating an Issue to have this fixed.

I have the same issue. I know its been a year but there still seems to be no solution.

I am having the same problem also.

Switch to JSON with Comments interpreter:
image

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…

Eg:

                "/Users/runger/.platformio/packages/framework-arduinoststm32/variants/STM32G4xx/G473R(B-C-E)T_G474R(B-C-E)T_G483RET_G484RET",

becomes:

                "/Users/runger/.platformio/packages/framework-arduinoststm32/variants/STM32G4xx/G473R\(B-C-E\)T_G474R\(B-C-E\)T_G483RET_G484RET",

This bug is already tracked per Bug with IntelliSense and paths - #3 by bumlebi.

2 Likes