Vscode-cpptools: -imacros flag ignored in compile_commands.json

Created on 16 Aug 2018  Â·  10Comments  Â·  Source: microsoft/vscode-cpptools

Type: LanguageService
----- Input information below -----
My compile_commands.json contains in the "command" section:

-imacros /home/johnflux/project/include/generated/autoconf.h

But intellisense says, for example: "identifier CONFIG_FOO is not defined" even though it is defined in that autoconf.h.

Setting "C_Cpp.loggingLevel": "6" I see:

sending compilation args for file.c

  include: myincludes.h
  define: __STDC__=1 etc

but no mention at all of autoconf.h

This is with the compiler: /opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/arm-zephyr-eabi/arm-zephyr-eabi-gcc

If I replace -imacros with -include then I correctly get:

preinclude: myproject/autoconf.h

So just treating -imacros as -include would probably be sufficient

Describe the bug

  • OS and Version: Linux, Ubuntu
  • VS Code Version: 1.26
  • C/C++ Extension Version: C/C++ 0.17.7
Feature Request Compile Commands Language Service fixed (release pending)

All 10 comments

@johnflux There is forcedInclude which you may use to include generated autoconf.h.
However, you would have to remove compileCommands completely, otherwise forcedInclude won't work. I am not sure if this is a bug or intended.

A workaround is to replace -imacros with -include, perhaps with a small sed script that you run after compiling.

I tried to patch this, but I can not seem to find the section of cpptools that parses the flags in compile_commands.json. Where in the code is the parsing of compile commands defined?

It's in our closed source language server code....so you'd have to have access to the Microsoft repo to fix it.

Any chance of a fix for this? It should be simple to just treat it like -i

On Thu, 20 Jun 2019, 08:18 Sean McManus, notifications@github.com wrote:

It's in our closed source language server code....so you'd have to have
access to the Microsoft repo to fix it.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/microsoft/vscode-cpptools/issues/2417?email_source=notifications&email_token=AAJMNJGQXSLQEMEQSAZ7KODP3K5FVA5CNFSM4FQBVSA2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYDRNZI#issuecomment-503781093,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJMNJH2U62CDU3URWCATCTP3K5FVANCNFSM4FQBVSAQ
.

It should represent quite a small change, and would go a long way toward being the preferred editor for embedded development with Zephyr. In the meantime, I'll try @johnflux 's workaround approach.

@johnflux Yeah, it looks like we'll be able to fix it for 0.25.0-insiders in July.

As of Aug. 8 2019, this issue remains. I am using the latest version.

Version: 1.36.1 (user setup)
Commit: 2213894ea0415ee8c85c5eea0d0ff81ecc191529
Date: 2019-07-08T22:59:35.033Z
Electron: 4.2.5
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.16299

We haven't released the insiders build yet, but hope to do so today. We are doing some final testing on it.

Was this page helpful?
0 / 5 - 0 ratings