Using .natvis file to visualise C++ objects in VS Code(使用 .natvis 文件在 VS Code 中可视化 C++ 对象)
问题描述
根据此链接,.natvis 文件可用于可视化原生对象.具体来说,我希望能够使用 Eigen::Matrix 对象.natvis?at=default&fileviewer=file-view-default%20eigen.natvis" rel="noreferrer">这个 .natvis 文件.
According to this link, .natvis files can be used to visualise native objects. Specifically, I would like to be able to inspect Eigen::Matrix
objects using this .natvis file.
但是,上面的链接不包含有关如何在 VS Code 中实际使用 .natvis 文件的任何信息.是否可以使用自定义 .natvis 文件?
However, the link above does not contain any information on how to actually use a .natvis file in VS Code. Is it possible using a custom .natvis file?
这是我的launch.json文件供参考:
Here is my launch.json file for reference:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++-8 build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "g++-8 build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
推荐答案
launch.json文件有一个visualizerFile选项:
The launch.json file has has a visualizerFile option:
{
"name": "g++-8 build and debug active file",
"visualizerFile": "${workspaceFolder}/path/to/file.natvis",
"showDisplayString": true,
...
},
这里有一些更多的文档(请参阅 VisualizerFile 和 showDisplayString 表条目):https://docs.microsoft.com/en-us/cpp/build/launch-vs-schema-reference-cpp?view=vs-2019#c-linux-properties
Some more documentation here (see the visualizerFile and showDisplayString table entries): https://docs.microsoft.com/en-us/cpp/build/launch-vs-schema-reference-cpp?view=vs-2019#c-linux-properties
您可能也对此问题感兴趣:https://github.com/Microsoft/vscode-cpptools/issues/925
You might also be interested in this issue: https://github.com/Microsoft/vscode-cpptools/issues/925
这篇关于使用 .natvis 文件在 VS Code 中可视化 C++ 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 .natvis 文件在 VS Code 中可视化 C++ 对象


- 我应该为我的项目使用相对包含路径,还是将包含目录放在包含路径上? 2022-10-30
- C语言qsort()函数的使用方法详解 2023-04-26
- 详解C语言中sizeof如何在自定义函数中正常工作 2023-04-09
- C语言详解float类型在内存中的存储方式 2023-03-27
- c++ const 成员函数,返回一个 const 指针.但是返回的指针是什么类型的 const? 2022-10-11
- Easyx实现扫雷游戏 2023-02-06
- C语言手把手带你掌握带头双向循环链表 2023-04-03
- C++ 数据结构超详细讲解顺序表 2023-03-25
- ubuntu下C/C++获取剩余内存 2023-09-18
- Qt计时器使用方法详解 2023-05-30