Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-D__FILENAME__=\\\"filename.c\\\" in compile_commands.json is not parsed properly #1795

Closed
schultetwin1 opened this issue Apr 6, 2018 · 8 comments
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service quick fix

Comments

@schultetwin1
Copy link

schultetwin1 commented Apr 6, 2018

We use cmake to generate a __FILENAME__ definition for each file that is passed into the command line. __FILENAME__ is the same as __FILE__ without the full path. In compile_commands.json this will show up in the command as -D__FILENAME__=\\\"filename.c\\\". The first backslash escapes the second backslash and the third backslash escapes the ". This is so that on the command line it will show up as -D__FILENAME__=\"filename.c\" so that the quotes are escaped for the command.

In vscode, the intellisense thinks __FILENAME__ is \"filename.c\" instead of "filename.c". This causes a red squiggle under the __FILENAME__ macro.

A quick repro of this issue is to add the following to a CMakeLists.txt

set(FILENAME filename.c)
target_compile_definitions(target PUBLIC __FILENAME__="${FILENAME}") 
@huww98
Copy link

huww98 commented Apr 7, 2018

I have the same problem with my ros project.

compile_commands.json contains something like -DROS_PACKAGE_NAME=\\\"my_package_name\\\" and VSCode show errors on every rosconsole calls (like ROS_FATAL("some message.");). If I change it to -DROS_PACKAGE_NAME=\"my_package_name\", then everything works.

@bobbrow
Copy link
Member

bobbrow commented Apr 9, 2018

Thanks for reporting this.

@sean-mcmanus
Copy link
Contributor

I hit this myself last week (from the repro project in #1777 ), but I didn't realize it was a bug.

@bobbrow
Copy link
Member

bobbrow commented Apr 9, 2018

I'm testing a fix for this right now.

@schultetwin1
Copy link
Author

Awesome, thank you!

@bobbrow bobbrow added the fixed Check the Milestone for the release in which the fix is or will be available. label Apr 17, 2018
@bobbrow
Copy link
Member

bobbrow commented Apr 24, 2018

A preview of this is available in the insiders build if you would like to try it out and provide feedback.

@schultetwin1
Copy link
Author

Just tried the preview. It worked great, thank you!

@bobbrow
Copy link
Member

bobbrow commented May 8, 2018

This is fixed in 0.17.0.

@bobbrow bobbrow closed this as completed May 8, 2018
@github-actions github-actions bot locked and limited conversation to collaborators Oct 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service quick fix
Projects
None yet
Development

No branches or pull requests

4 participants