code-gnu-global
code-gnu-global copied to clipboard
Go to Definition for functions declared outside the project folder
I'm using the procedure described to add folders and index files external to the project folder as per 2.3 Applied usage in the GNU GLOBAL Source Code Tag System tutorial.
$ cd project/folder
$ (cd /external/path1; gtags)
$ (cd /external/path2; gtags)
$ export GTAGSLIBPATH=/external/path1:/external/path2
Let's consider function_in_path1()
declared in file /external/path1/functions1.cpp
with the corresponding header. The main.cpp
includes /external/path1/functions1.h
and calls function_in_path1()
.
When pointing on function_in_path1()
and calling the contextual menu, the options Go to Definition
, 'Peek Definitionand
Find All Referencesare displayed but none of them actually works. However,
global function_in_path1` returns the right path and file.
$ cd project/folder $ global function_in_path1 ../../../../external/path1/functions1.cpp
Thank you!
Did you run code from the same shell after GTAGSLIBPATH is exported?
Good point!
I launched VSC as a standard app on my Mac, but I created the indexes with gtags
and set the GTAGSLIBPATH
variable on a Terminal window.
So the question might be now, how to set the GTAGSLIBPATH
variable within VSC.
As a workaround, refer to https://code.visualstudio.com/Docs/editor/setup on how to setup vscode to launch from command line on OS X.
I will probably add an extension setting to set this env variable within vscode.
Thank you for the pointer!