gpt4 book ai didi

c++ - 使/欺骗 Visual C++ 正确地缩进宏结构

转载 作者:太空宇宙 更新时间:2023-11-04 11:25:28 24 4
gpt4 key购买 nike

考虑这些宏

#define BEGIN(Parent) void Process(){

#define ELEMENT(Elem) RegisterElement(Elem);

#define END }

使用它们时,Visual Studio 不会将 ELEMENT 识别为子代码块的一部分,因此无法正确缩进

BEGIN(ParentClass)   <--- hit ENTER here and carret will go below `B` in begin, with no indentation
ELEMENT(m_member)
END

有没有一种方法可以欺骗 Visual Studio,比如我可以编写宏代码或一些有用的编译指示,以便 Visual Studio 识别 RegisterElement 函数的开始和结束范围,从而插入 ELEMENT 条目是否正确?谢谢

最佳答案

为 VS 2013/12/10 使用代码对齐扩展

这是网址:https://visualstudiogallery.msdn.microsoft.com/7179e851-a263-44b7-a177-1d31e33c84fd

从“编辑”->“代码对齐”菜单中,选择“从插入符对齐”

enter image description here

关于c++ - 使/欺骗 Visual C++ 正确地缩进宏结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26827036/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com