-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Cannot properly set Include and Defines with third-party compilers #4269
Comments
hi, |
@CfirTsabari Using "**" with system includes is not recommended because the ordering may not be correct. If subfolders are required, it's better to just list them in the correct order. @gentooise Our compiler only supports emulation of cl.exe, gcc, and clang, so it needs to be set to one of these modes. It looks like our C/C++: Log Diagnostics command has a bug in the compile_commands.json scenario where it is showing the c_cpp_properties.json instead of the defines obtained from the compile_commands.json -- I could file a new bug for that: #4270 . Our compile_commands.json and configurationProvider were designed to ignore the includePath and defines in c_cpp_properties.json, unless a source file is encountered that doesn't have configuration info. One workaround is to set your compilerPath to a .bat (Windows) or .sh (Linux/Mac) script that outputs the system includes and defines you want, such as
Let us know if that workaround doesn't work for you. We have a fix pending for the lack of support for "${workspaceFolder}" in the compilerPath and compilerArgs: #3440 . |
Actually, it looks like the arm compiler should be "the same" as gcc. Can you check what error occurs when you specific that compiler as the compilerPath? Is our mechanism for querying the compiler for system includes and defines failing? enabling debug logging might give better failure info. |
Is the ARM compiler you're using publicly available for us to try out? |
Also, we don't have the proper flags/settings enabled to give 100% correct results for ARM -- specifically we need to add intelliSenseMode's for gcc-arm, gcc-arm64, clang-arm, clang-arm64, windows-arm, windows-arm64 support. I should file a new issue to track that: #4271 |
Ok, is it only an aesthetic problem then?
I understand. I will try ASAP and let you know, but I do not understand some details of the expected output format (
Unfortunately not, ARM Compiler is not the same as GCC, it is a commercial compiler that has its own includes, macros, and command line arguments. I can put it in
My point is that it could be useful to have a generic way to handle compilers that are not specifically supported: your hint about a script file could be one way to do it. Another way could be to have the possibility to (manually) put other includes/defines in addition to the ones found in
Unfortunately not, it can be only used by purchasing a license.
Please note that the compiler is not gcc-arm or clang-arm. The correct names are Finally, I have another question: which is the purpose of the |
Yes it is failing because it seems to switch to MinGW GCC. This is the output of Log Diagnostics:
As you can see, it assumes that the compiler is MinGW GCC, and takes in all its include paths. Anyway, I enabled debug logging but I don't see any output difference, please tell me where to find debug logs (if any). |
I tried also this, and I got the same result as above (same Log Diagnostics), except for the line: where compile.bat contains the following:
|
Yeah, the defines being incorrect is a bug in the logging output. The If you're using CMake and the CMake Tools extension, you would probably get better results if you set the configurationProvider setting and not the compileCommands setting. Is the CMake Tools extension able to get the correct system includes/defines? The .bat file probably doesn't work because haven't shipped the fix for |
Got it, thanks.
I'm probably not using the CMake Tools extension correctly, because I get this when opening cpp files:
I used |
UPDATE: I'm going on with the batch script strategy and I noticed that also parenthesis need to be escaped with c_cpp_properties.json:
compile.bat:
I get the following Log Diagnostics:
I think this is really close to be solved, but I still see the following issues:
|
UPDATE2: I made another step forward on issue 1 above:
In general I understood that, as a rule of thumb, any non-standard compiler built-in directive should be defined manually (as Right now I think my only remaining issues are the following:
|
The CMake Tools extension doesn't read compile_commands.json -- it reads the CMakeLists.txt (and/or the CMake cache files) directly. Go to Def on You could try adding the folders to files.exclude (make sure it doesn't end with a "/", since we haven't shipped the fix for that case yet). We don't handle "*" (non-recursive paths) in the results from the compiler currently -- i.e. it's a bug: #4296 . Ideally, we would add arm modes (#4271), but to get gcc-x86 to be used, you should set defines |
files.exclude seems enough as a workaround for now, thank you.
I added these lines to the
but cpptools now falls back to |
@gentooise Ah, yeah, thanks for reporting that -- I see in the code where it's setting it to gcc-x64. I filed bug #4353 . I think we'll be able to fix that for our next release (update: it should be fixed in our next Insiders release, today or tomorrow). |
@gentooise The x86 mode not being used should be fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/0.26.0-insiders . Let us know if it's not working for you. |
That's perfect: Thanks. |
I'm coming late to the discussion. We should write up some documentation about how to work with unsupported compilers. I think a better approach is to use a combination of the |
Thanks for the hint. I tried your approach, but it is partially working for me. It is ok for In particular, I'm using However, according to this article, Here diagnostic logs (which shows my system defines anyway, even if they are not used by IntelliSense):
|
Type: LanguageService
Describe the bug
compileCommands
plus other global includes/defines taken fromincludePath
anddefines
properties respectively.I'm using a third-party compiler (ARM) which has its own includes and defines, but I also need to use project-related include/defines taken from
compile_commands.json
(generated via CMake).I'm trying to set compiler-specific includes/defines manually, and then use
compileCommands
property for project-specific includes/defines.This is a minimal version of my
c_cpp_properties.json
:Also I would like to set something like
"intelliSenseMode": null
, because neither MSVC, GCC nor CLang are correct choices for my case. Why does IntelliSense need this info?This is the full Log Diagnostics output (except sensitive paths):
This is a screenshot to show the problems encountered:
![image](https://user-images.githubusercontent.com/1735060/65161717-588a6780-da38-11e9-9c56-b97c5b38ffa5.png)
I see 3 main problems:
includePath
specified inc_cpp_properties.json
, but only the paths found incompile_commands.json
; Since myincludePath
is not present, the compiler headers are not recognized (e.g.string.h
is not found as you can see from the screen);c_cpp_properties.json
but does not contain the ones fromcompile_commands.json
; moreover, even if the macro is present in the list (e.g.__ARM__
), the editor does not recognizes it and the wrong preprocessor branch is greyed out!Expected behavior
In the Log Diagnostics I expect to see the union of includes/defines from both
c_cpp_properties.json
andcompile_commands.json
, and I expect them to work in the editor.The text was updated successfully, but these errors were encountered: