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

Struct definition inside function not supported #2442

Closed
sguillia opened this issue Aug 22, 2018 · 8 comments
Closed

Struct definition inside function not supported #2442

sguillia opened this issue Aug 22, 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
Milestone

Comments

@sguillia
Copy link

Type: LanguageService

Description

The language service fails to parse struct definitions that occur inside function scope.

Please take a look at those screenshots.

Screenshot 1
vscode-bug-cpp-1
Screenshot 2
vscode-bug-cpp-2

To Reproduce

  • Open these files and change extension to .c
    test.txt
    test2.txt
  • Do as in screenshots

Expected behavior

Expected in screenshot 1: d, e and f show up instead of a, b, c which make no sense
Expected in screenshot 2: After pressing F12 (Go to definition), the definition on line 5 should be focused.

Screenshots
See above

Additional context

VS Code version: Code - Insiders 1.27.0-insider (e0a68266321d1518bc12428b71d80524461a275b, 2018-08-22T05:18:13.273Z)
OS version: Windows_NT x64 10.0.15063

System Info
Item Value
CPUs Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz (8 x 3408)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 15.89GB (10.36GB free)
Process Argv C:\Users\GUILLIAMS.S\AppData\Local\Programs\Microsoft VS Code Insiders\Code - Insiders.exe
Screen Reader no
VM 50%
Extensions (5)
Extension Author (truncated) Version
code-gnu-global aus 0.2.2
favorites kdc 1.7.3
cpptools ms- 0.18.1
vscode-fileutils sle 2.10.3
vim vsc 0.16.0

(1 theme extensions excluded)

@bobbrow
Copy link
Member

bobbrow commented Aug 22, 2018

I think the problem is the green squiggle at the top of the file. It causes us to switch IntelliSense over to our tag parser implementation which does not parse out local variables and types.

image

Can you share your c_cpp_properties.json file? I suspect that either something is misconfigured, or the extension was unable to locate the standard headers on your PC.

The Goto defintion issue is known and we are tracking it with #255.

@sguillia
Copy link
Author

The file c_cpp_properties.json file does not exist.

I indeed ignored the green squiggles because I don't care if standard headers are not found.

It is normal that the extension didn't find them because they are in an unusual directory.

It causes us to switch IntelliSense over to our tag parser implementation

When removing #include <stdio.h>, the autocompletion works and propose d, e and f.
But how can I force the extension to stay in the "normal" mode?

I don't really want to fix the missing include if it isn't absolutely required since it is an extra effort to me.

@bobbrow
Copy link
Member

bobbrow commented Aug 23, 2018

Click on the green squiggle, then click on the lightbulb that appears and select "force semantic IntelliSense"

@sguillia
Copy link
Author

When removing #include <stdio.h>, the autocompletion works as expected.

When forcing semantic IntelliSense ("C_Cpp.intelliSenseEngineFallback": "Disabled"), the autocompletion does not work for any of the structures I've declared (item1 and item2).

If I remove the include, then it works again as expected, no matter if semantic IntelliSense was forced.

@bobbrow
Copy link
Member

bobbrow commented Aug 24, 2018

Thanks for the info. I can reproduce your issue. We'll investigate.

@sean-mcmanus
Copy link
Contributor

The Go to Definition on "bar" has been fixed with 0.19.0. I'm not able to repro the completion issue with the fallback even with 0.18.1 -- @bobbrow since you appear to have gotten a repro can you see if it's still a bug? Did you ever investigate this yet?

@sean-mcmanus sean-mcmanus added more info needed The issue report is not actionable in its current state not reproing We're not able to reproduce the issue (it's unlikely to get fixed until we find one). labels Sep 28, 2018
@bobbrow
Copy link
Member

bobbrow commented Sep 28, 2018

My repro involves recursive includes, and an empty compilerPath string which results in no include directories being sent to the IntelliSense server. This causes an error in the server when any #include is attempted in the file.

For the time being, you should be able to work around this issue by adding any non-recursive path to your includePath in c_cpp_properties.json (e.g. "${workspaceFolder}")

@bobbrow bobbrow removed more info needed The issue report is not actionable in its current state not reproing We're not able to reproduce the issue (it's unlikely to get fixed until we find one). labels Sep 28, 2018
@sean-mcmanus sean-mcmanus modified the milestones: On Deck, October 2018 Sep 28, 2018
@sean-mcmanus sean-mcmanus self-assigned this Sep 28, 2018
@sean-mcmanus sean-mcmanus added the fixed Check the Milestone for the release in which the fix is or will be available. label Sep 28, 2018
@sean-mcmanus sean-mcmanus removed their assignment Sep 28, 2018
@sean-mcmanus
Copy link
Contributor

The completion issue should be fixed with 0.20.0.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 13, 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

3 participants