-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
gnu17 isn't being used for .c files with "compile_commands.json" #6279
Comments
This is caused by gnu11 or gnu17/18 not being used as the cStandard. With CMake Tools, I'm seeing c11 being used instead and with compile commands I'm seeing c++17 being used. |
A workaround might be to stop using compileCommands and configurationProvider and changing cStandard to gnu11. |
After the compileCommands is modified, I'm seeing it switch to c17, but it's not using the cStandard specified in the compileCommands. |
The compile commands issue is fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/1.1.0-insiders . The CMake Tools issue is being tracked by microsoft/vscode-cmake-tools#1477 . |
Thanks for the quick fix. I got it working in a test project, however the exact same file has the same issues when placed in a real project, one that does not use CMake Tools configuration provider, which, I guess still waits for a fix. Could be a user error, I'll do some further investigations and get back to you. Also, since 1.50.0 I've noticed some similar issues with IntelliSense not finding system header dependencies such as |
When you do C/C++: Log Diagnostics is the "Standard version" correct? Might also be related to #6324 . |
Can you do a C/C++: Log Diagnostics so we can tell what cStandard is being used? |
|
Your cStandard needs to be either removed (so that the default is used) or changed to "gnu11" -- 1.1.0-insiders2 fixed a bug in which that was not used, i.e. the regression you're seeing with the latest version is actually a bug fix. Let me know if that doesn't fix your issue. Note that the logging won't show "gnu11" being used (it'll be reported as c11), even when gnu11 is actually being used, which is potentially confusing. |
Okay -- I'm seeing a bug now with the gnu part not working. |
Ah, okay, it's working for me now (I was confused by _GNU_SOURCE not being defined, but that's just for C++). But you have to do a Reload Window after changing c11 to gnu11. I'll file a bug on that. |
I believe all of those |
Okay, I made it work now with v1.1.0-insiders2, thanks! |
Well, kind of. It does not work with files that contain spaces in names:
|
Yes, it happens after Reload Window as well.
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
project(test C)
add_executable(test "test file.c")
{
"C_Cpp.default.compileCommands": "${workspaceFolder}/build/compile_commands.json",
"C_Cpp.default.configurationProvider": "${default}"
}
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <netinet/in.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
char buffer[PATH_MAX] = { 0 };
struct in6_addr a, b;
printf((optarg = "%s\n"), buffer);
IN6_ARE_ADDR_EQUAL(&a, &b);
return 0;
} |
Yeah, I'm still not reproing the issue with the space in the filename. If you see PATH_MAX being defined, then gnu11 is being used. It looks like there's some issue with in6_addr. What does it open when you go to definition on in6_addr? The error in the screenshot seems to indicate that the in6_addr definition isn't being found, perhaps due to missing defines. @Colengms @michelleangela Can someone double check if they can repro this? |
gcc-5 @ Ubuntu 16.04:
|
It is not greyed out. In .c file without space in filename IntelliSense works normally while in a file with space it doesn't. Both files are part of the same project. |
Hi @dslijepcevic . Can you provide the contents of the C/C++ Output channel (with Is it possible that the file was added to |
It happens after Reload window too, so there are no "entry not found" errors that I see. LogsC/C++ Log Diagnostics:
Log from the language server:
|
@dslijepcevic Thanks for the info -- the incorrect logging "Compiler probe command line: "/usr/bin/cc" -g /proj/test2/test file.c -std=gnu11 -Wp,-v -E -dD -x c -m64 /dev/null" helped me figure it out -- the "/proj/test2/test file.c" test should not be there, most likely a bug in the code that removes the |
I've moved that issue to #6339 . |
Hi @dslijepcevic . I also replied in the issue Sean created. I believe the command line you have for the file with the space in it, is ill formed. When I try to do something similar, I get an error from gcc that it cannot find the file "/proj/test2/test". Did you add this manually to
Otherwise, the space will be treated as beginning a new argument. |
Yes, but CMake does generate this properly I think: [
{
"directory": "/proj/test/build",
"command": "/usr/bin/cc -g -o CMakeFiles/test.dir/test_file.c.o -c \"/proj/test/test file.c\"",
"file": "/proj/test/test file.c"
}
] It's probably someone who parses this file afterwards. |
Sorry, @dslijepcevic , my mistake. I can repro the issue with quoted args w/spaces, and have a fix that should go into the next insiders. |
@dslijepcevic Should be fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/1.1.1 |
Type: LanguageService
Describe the bug
IntelliSense does not work properly with the following code snippet when
compile_commands.json
are being used:test.c
:CMakeLists.txt
:Steps to reproduce
It seems that the problem occurs when
compile_commands.json
are being used, either manually or via a configuration provider. This can be reproduced with the followingc_cpp_properties.json
:When
"compileCommands"
gets commented out the problem goes away:Logs
C/C++ Log Diagnostics before CMake configures IntelliSense:
C/C++ Log Diagnostics after CMake configures IntelliSense:
Log from the language server:
The text was updated successfully, but these errors were encountered: