Post

C의 구조체 값을 미리볼 수 있게 해보자

목차


구조체 값 미리보기 (natvis)

launch.json object 안에 해당 옵션 추가

1
2
"visualizerFile": "${workspaceFolder}/.vscode/httpgw.natvis",
"showDisplayString": true,

이후 ${workspaceFolder}/.vscode 디렉토리에 httpgw.natvis 파일 추가

(.natvis 작성 규칙)

https://docs.microsoft.com/ko-kr/visualstudio/debugger/create-custom-views-of-native-objects?view=vs-2019#modify-natvis-files-while-debugging

https://docs.microsoft.com/ko-kr/visualstudio/debugger/format-specifiers-in-cpp?view=vs-2019

파일 추가 후 해당 항목 작성

1
2
3
4
5
6
7
8
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
    <Type Name="string_t">
        <DisplayString>{{data={(char*)data}}}</DisplayString>
        <Expand>
            <Item Name="str">(char*)data</Item>
        </Expand>
    </Type>
</AutoVisualizer>
This post is licensed under CC BY 4.0 by the author.