在Visual Studio中,您可以自定义任何显示项的字体和颜色,例如C ++关键字,C ++参数,C ++局部变量,函数名称,宏等。您可以通过选择菜单“工具 - >”来完成此操作。选项 - >字体和颜色“。
在设置对话框中,我对两个“显示项目”感到困惑:“C ++ Local Variables”和“C ++ Variables”。
“C ++ Local Variables”很容易理解。说:
void f()
{
int this_is_a_Cpp_Local_Variable;
}
我可以将C ++局部变量设置为我喜欢的任何字体和颜色。
然而,我无法理解“C ++变量”是什么。我已经测试并证明它们不是全局变量,无论全局变量是基本类型还是用户定义类型。
我的问题是:Visual Studio的“显示项目”中的“C ++变量”是什么?
更新
我的测试代码是:
#include <iostream>
#include <functional>
using namespace std;
class A
{
public:
int n;
};
A a;
class B
{
public:
B()
{
int v;
a.n
}
};
void f(A a)
{
a.n;
}
int main()
{
int v;
A a;
}
vssettings:
<UserSettings>
<ApplicationIdentity version="11.0"/>
<ToolsOptions>
<ToolsOptionsCategory name="Environment" RegisteredName="Environment"/>
</ToolsOptions>
<Category name="Environment_Group" RegisteredName="Environment_Group">
<Category name="Environment_FontsAndColors" Category="{1EDA5DD4-927A-43a7-810E-7FD247D0DA1D}" Package="{DA9FB551-C724-11d0-AE1F-00A0C90FFFC3}" RegisteredName="Environment_FontsAndColors" PackageName="Visual Studio Environment Package">
<PropertyValue name="Version">2</PropertyValue>
<FontsAndColors Version="2.0">
<Categories>
<Category GUID="{58E96763-1D3B-4E05-B6BA-FF7115FD0B7B}" FontName="Fixedsys Excelsior 3.01" FontSize="12" CharSet="1" FontIsDefault="No">
<Items/>
</Category>
<Category GUID="{75A05685-00A8-4DED-BAE5-E7A50BFA929A}" FontName="Fixedsys Excelsior 3.01" FontSize="12" CharSet="1" FontIsDefault="No">
<Items>
<Item Name="Literal" Foreground="0x000000FF" Background="0x01000001" BoldFont="No"/>
<Item Name="String" Foreground="0x000000FF" Background="0x01000001" BoldFont="No"/>
<Item Name="CppMacroSemanticTokenFormat" Foreground="0x000000FF" Background="0x01000001" BoldFont="No"/>
<Item Name="CppEnumSemanticTokenFormat" Foreground="0x000000FF" Background="0x01000001" BoldFont="No"/>
<Item Name="CppGlobalVariableSemanticTokenFormat" Foreground="0x000000FF" Background="0x00008000" BoldFont="No"/>
<Item Name="CppLocalVariableSemanticTokenFormat" Foreground="0x00000080" Background="0x01000001" BoldFont="No"/>
<Item Name="CppParameterSemanticTokenFormat" Foreground="0x00000000" Background="0x01000001" BoldFont="No"/>
<Item Name="CppTypeSemanticTokenFormat" Foreground="0x00FF0000" Background="0x01000001" BoldFont="No"/>
<Item Name="CppRefTypeSemanticTokenFormat" Foreground="0x00FF0000" Background="0x01000001" BoldFont="No"/>
<Item Name="CppValueTypeSemanticTokenFormat" Foreground="0x00FF0000" Background="0x01000001" BoldFont="No"/>
<Item Name="CppFunctionSemanticTokenFormat" Foreground="0x00000080" Background="0x01000001" BoldFont="No"/>
<Item Name="CppMemberFunctionSemanticTokenFormat" Foreground="0x00000080" Background="0x01000001" BoldFont="No"/>
<Item Name="CppStaticMemberFunctionSemanticTokenFormat" Foreground="0x00000080" Background="0x01000001" BoldFont="No"/>
<Item Name="CppClassTemplateSemanticTokenFormat" Foreground="0x00FF0000" Background="0x01000001" BoldFont="No"/>
<Item Name="CppGenericTypeSemanticTokenFormat" Foreground="0x00FF0000" Background="0x01000001" BoldFont="No"/>
<Item Name="CppFunctionTemplateSemanticTokenFormat" Foreground="0x00000080" Background="0x01000001" BoldFont="No"/>
<Item Name="CppNamespaceSemanticTokenFormat" Foreground="0x000000FF" Background="0x01000001" BoldFont="No"/>
<Item Name="CppLabelSemanticTokenFormat" Foreground="0x000000FF" Background="0x01000001" BoldFont="No"/>
<Item Name="VA X Brace Matching" Foreground="0x02000000" Background="0x02000000" BoldFont="Yes"/>
</Items>
</Category>
<Category GUID="{B36B0228-DBAD-4DB0-B9C7-2AD3E572010F}" FontName="Microsoft YaHei" FontSize="9" CharSet="1" FontIsDefault="No">
<Items>
<Item Name="Different content" Foreground="0x000014E5" Background="0x00FFFFFF" BoldFont="No"/>
<Item Name="Identical content" Foreground="0x00000000" Background="0x00FFFFFF" BoldFont="No"/>
<Item Name="Source Only" Foreground="0x00000000" Background="0x00FFFFFF" BoldFont="No"/>
<Item Name="Target Only" Foreground="0x00000000" Background="0x00FFFFFF" BoldFont="No"/>
<Item Name="Not Downloaded" Foreground="0x006D6D6D" Background="0x00FFFFFF" BoldFont="No"/>
<Item Name="Even Row Items" Foreground="0x00000000" Background="0x00FFFFFF" BoldFont="No"/>
<Item Name="Odd Row Items" Foreground="0x00000000" Background="0x00FFFFFF" BoldFont="No"/>
</Items>
</Category>
<Category GUID="{E0187991-B458-4F7E-8CA9-42C9A573B56C}" FontName="Fixedsys Excelsior 3.01" FontSize="12" CharSet="1" FontIsDefault="No">
<Items>
<Item Name="String" Foreground="0x000000FF" Background="0x01000001" BoldFont="No"/>
</Items>
</Category>
<Category GUID="{FF349800-EA43-46C1-8C98-878E78F46501}" FontName="Fixedsys Excelsior 3.01" FontSize="12" CharSet="1" FontIsDefault="No">
<Items/>
</Category>
</Categories>
</FontsAndColors>
</Category>
</Category>
</UserSettings>
答案 0 :(得分:1)
正如您所看到的,它突出显示了C ++项目中不同类型的变量。这是带有自定义颜色方案的Visual Studio 2012。
blue := local
green := global variable
所以这是我的设置突出显示的代码:
这是您的colorsettings,背景颜色为红色的局部变量