-
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
function with the name "new" messes with folding and formatting #8381
Comments
Hi @stanle-cs . I'm able to reproduce the folding issue in VS. (The C/C++ Extension shares code for various features with VS). I've opened a bug internally for that issue. I'm not able to reproduce a formatting/indentation issue. Could you provide more info on how to reproduce that? Could you provide any formatting settings you have specified, as well as any VS Code settings you've set that refer to 'indent'? |
Hi @Colengms , I've updated the report with the format settings I'm using. I also forced the use of VcFormat as the formatting engine. |
Also, I should mention that the diagnostics you provided indicates the file |
@Colengms If that's the case then this should be another bug, I don't have any custom association settings for my project. |
Hi @stanle-cs . I needed to enable |
Hi @stanle-cs . I'm not able to easily reproduce the incorrect language selection issue locally. I would need more information to determine why that is happening. Can you provide a stand-alone example I could use to investigate further? (Perhaps in the form of a git repo?) The following indicators in the Log Diagnostics point to C++ being used when you collected that log:
Also, I do not see any "Custom configurations:" section in your Log Diagnostics output, so it would appear that the file was not configured by CMake Tools in that case. (Or, it had been configured according to the 'custom browse config', but a configuration for that specific file was not provided). Had you run |
Hi @Colengms I tried to reproduce the bug itself too but could not consistently make it work. Basic idea is that, if I were to create a new project with a new However this behavior seems pretty random since I tried to reproduce it a couple of times to no avail. I have definitely had that happen to me before though, since now that you mention it, for a while the extension was giving me error wiggles with the error As for the lack of "Custom configurations:" section, I have no idea why that's the case. I used a key binding to map Here's a repo with the codes I'm working with, hopefully you can trigger the bug with these files occasionally: Association Bug |
Got the bug that parse .c file as C++ source again. This time I can reproduce it. Create a new project, don't run EDIT: even after running C/C++ diagnostic
|
Hi @stanle-cs . I think I might know what's happening. If you had previously run There are currently some limitations of the custom browse configuration. It provides a compiler path, compiler args, and a standard version, but only for one language, C or C++. That said, I don't see a 'standard' included in your browse configuration at all. You should be able to get this process to default to C instead of C++ by specify the language standard version to CMake, either using something like If this is indeed what is happening, let me know, and we can convert this issue into a request to improve the custom browse configuration such that it includes sufficient information for configuring both C and C++ sources properly. |
Hi @Colengms , sorry for the late reply. EDIT: I realized that whenever I change the name of a source file the same error will also show up until I rerun configure. Here's the situation I'm having (hopefully you can duplicate the same behavior using the git repo).
It is now even weirder because the standard used is c++17 but the flags are set to gcc! I therefore have to rerun
Here's a C/C++ diagnostics when I create a new
|
Hi @stanle-cs . I think you have uncovered a couple of bugs here, and I've got fixes that should make it into the next release. When you first create a header file, and it's not yet included in any source files, the header is treated as C++ by default by VS Code. You could change that behavior with the following setting:
Does that work around your immediate issue? A custom configuration provider provides configurations for source file, but is not aware of header files. Once a source file includes the header, the header should be interpreted as the same language as the source file. (If multiple files include the header, and some are C and others C++, it will pick one). I did find a couple of bugs around this logic (around when the original source file the header was associated with gets closed), which we will fix. |
CMake Tools is capable of providing configurations for headers if the headers are added to the executable/library target in your CMakeLists.txt. We do it for our build of cpptools, but I don't think it's common practice. I thought that cpptools avoids asking for header configurations by doing the header->source map lookup first though. So there would be fewer cases where a request for a header configuration would actually happen. |
This issue has been closed automatically because it needs more information and has not had recent activity. |
Issue Type: Bug
Enable C/C++ extension.
Create a function new() in a .c file (ANSI-C compiled with
-ansi -pedantic
):{
not at thevoid * new(…)
lineExtension version: 1.7.1
VS Code version: Code 1.62.1 (f4af3cbf5a99787542e2a30fe1fd37cd644cc31f, 2021-11-05T10:57:55.946Z)
OS version: Windows_NT x64 10.0.22000
Restricted Mode: No
Vc Format Setting
Minimal c_cpp_properties.json to reproduce problem
C/C++ diagnostics
System Info
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
A/B Experiments
The text was updated successfully, but these errors were encountered: