简体   繁体   English

在Python文件(VSCode)中时钻取到C源代码定义

[英]Drill to C source code definition when in a Python file (VSCode)

I want to navigate to the definition of modules implemented in C from my Python file. 我想从我的Python文件导航到用C实现的模块的定义。

VSCode can drill to the definitions of my python objects. VSCode可以钻取到我的python对象的定义。 Some are found automatically, while others, I need to point to. 有些是自动找到的,有些则需要指出。

To add additional locations I add the following to my user VSCode settings: 要添加其他位置,请将以下内容添加到我的用户VSCode设置中:

"python.autoComplete.extraPaths": [
    "C:/Users/me/Desktop/external_python"
],

This works fine and I can right click on objects and 'Go To Definition'. 这可以正常工作,我可以右键单击对象并单击“转到定义”。

I want to drill even further; 我想进一步钻探; into the C implementation. 进入C实现。 Now, python modules implemented in C are compiled. 现在,编译了用C实现的python模块。 However, I have access to the *.h and *.c files which generated the shared objects. 但是,我有权访问生成共享库的* .h和* .c文件。 So, theoretically, I could jump from my python files into .h/.c files of C from within VSCode 因此,从理论上讲,我可以从VSCode中从python文件跳转到C的.h / .c文件

Is it possible to navigate from a python file into the source code of a compiled module? 是否可以从python文件导航到已编译模块的源代码?

It's not possibly to drill down from the Python code to the matching C code via definition. 通过定义不可能从Python代码深入到匹配的C代码。 Visual Studio may provide such functionality, but since VS Code lacks any direct ties to the object files there's no way to do the reverse lookup from Python name, to object file, to original source. Visual Studio可能提供了这样的功能,但是由于VS Code与目标文件没有任何直接联系,因此无法进行从Python名称到目标文件到原始源的反向查找。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 vscode (python) 中执行 ctrl+click(go to definition) 时查看库中的源代码 - How to see the source code inside the library when doing ctrl+click(go to definition) in vscode (python) 如何在python源代码中找到运算符的定义? - How to find the definition of an operator in the python source code? 没有找到 function 的定义 - VSCode Python - No definition found for function - VSCode Python Python反射 - 我可以使用它来获取方法定义的源代码 - Python reflection - Can I use this to get the source code of a method definition Python编译器/解析器中FloorDivide的定义/源代码在哪里? - Python where is the definition/source code of FloorDivide in the compiler/parser? 在没有定义行的情况下获取Python函数的源代码 - Getting a Python function's source code without the definition lines 从 VSCode 保存 python 文件 - 保存为源文件 - Saving python files from VSCode - saving as source file vscode python中mypy>=0.780的“源文件发现两次”错误 - “Source file found twice” error with mypy>=0.780 in python for vscode 当我在终端中编写 python 代码时,它只打印文件的旧版本(VScode) - When I write python code in terminal it only prints older version of the file (VScode) 在 vscode 中使用 code-runner 运行 python 文件时出错 - Error occurred when using code-runner to run python file in vscode
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM