本文介绍了使用.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/zh-cn/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 ++对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 20:36