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++ 对象
基础教程推荐
- C++使用easyX库实现三星环绕效果流程详解 2023-06-26
- 如何C++使用模板特化功能 2023-03-05
- C++详细实现完整图书管理功能 2023-04-04
- 详解c# Emit技术 2023-03-25
- C++中的atoi 函数简介 2023-01-05
- C语言基础全局变量与局部变量教程详解 2022-12-31
- C利用语言实现数据结构之队列 2022-11-22
- 一文带你了解C++中的字符替换方法 2023-07-20
- C/C++编程中const的使用详解 2023-03-26
- C语言 structural body结构体详解用法 2022-12-06