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

Go to Definition is not correct! It go to the .h file, not source file #1332

Closed
michaelllh opened this issue Dec 11, 2017 · 9 comments
Closed

Comments

@michaelllh
Copy link

michaelllh commented Dec 11, 2017

* Operating System and version  : win7 64bits
* VS Code version : 1.18.1
* C/C++ extension version : 0.14.3
* Other extensions: none
* step-by-step instructions to reproduce the issue:

Editing C/C++ file,choose function and goto the definition, it won't go to the right definition, some time it go to .h file,But I really define it in the project .c file.

@michaelllh michaelllh changed the title Go to Definition is not correct! Go to Definition is not correct! It go to the .h file, not source file Dec 11, 2017
@sean-mcmanus
Copy link
Contributor

We need more repro details. Go to Definition on a newly added definition only works after you save a file. Also, the feature returns all matching results from the symbol parsing and doesn't yet use the IntelliSense compiler to choose the correct definition. Are you able to get the correct definition to appear in the list of Go to targets? The feature also doesn't work on local variables yet.

@sean-mcmanus sean-mcmanus added Language Service more info needed The issue report is not actionable in its current state labels Dec 11, 2017
@LeThiHyVong
Copy link

LeThiHyVong commented Dec 12, 2017

@sean-mcmanus I have exactly same problem.
It appear that if the definition is in a big cpp (my file is 30000 lines) then Intellisense fails to parse (#1197). But the declaration in (short) header is fine and Go to Definition jump to the declaration.
I have to use C++ Intellisense extension base on GNU tag global instead.

@JcobCN
Copy link

JcobCN commented Dec 27, 2017

back to cpptools 0.13.0, it works well.

@sean-mcmanus
Copy link
Contributor

@michaelllh Does the lastest update fix your issue? https://github.com/Microsoft/vscode-cpptools/releases/latest .
@jiangcn We fixed some regressions caused by 0.13.1. Let us know if it's working now.

We're still have some issues if your file has UTF-8 characters > 1 byte: #1439

@brianignacio5
Copy link

brianignacio5 commented Jun 15, 2018

Using cpptols 0.17.4
Cmake tools 1.0.1

Project : https://files.fm/u/zsnyk2j9

Steps to reproduce (In Linux based):

  1. Extract folder cmake_test_vscode to any location {dir}.
  2. Run code {dir}/cmake_test_vscode/project
  3. Run a cmake build using Cmake tools command : Cmake: Build
  4. Hover test() in project/main.c and Go to declaration/definition

We observe that it goes to the test.h file but not to the test.c source.

Going to the actually symbol definition is really important. Could contribute but don't know how to start.

@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Jun 15, 2018

@brianignacio5 It works if you use

            "browse": {
                "path": [
                    "${workspaceFolder}/../dependency"
                ],
                "limitSymbolsToIncludedHeaders": false
            }

There are long-standing bugs on these issues (issues exist on GitHub):

  1. The browse.path isn't automatically generated from the compile_commands.json
  2. The non-workspaceFolder paths are not parsed for source files if limitSymbolsToIncludedHeaders is set to the default value of true.

We might be able to fix issue 2 in June and 1 in July (depending on other priorities).

@brianignacio5
Copy link

Thanks for your reply @sean-mcmanus !!

Following up on browse.path functionality, would we be able to obtain the compiled .c source files from the compile_commands.json? Having just the list of directories can present conflicts on mutually exclusive sources ( which are selected upon different settings).

@sean-mcmanus
Copy link
Contributor

@brianignacio5 Yeah, I think we should be able to parse only the source files listed in the compile_commands.json. The 2nd issue should be fixed in our next release.

@bobbrow bobbrow added duplicate and removed more info needed The issue report is not actionable in its current state labels Feb 4, 2019
@bobbrow
Copy link
Member

bobbrow commented Feb 4, 2019

This issue appears to be a duplicate of another issue: #1715

@bobbrow bobbrow closed this as completed Feb 4, 2019
@github-actions github-actions bot locked and limited conversation to collaborators Oct 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants