如何获得C(不是C ++)语法在Visual Studio(2010年)突出? [英] How to get C (not C++) syntax highlighting in Visual Studio (2010)?

查看:169
本文介绍了如何获得C(不是C ++)语法在Visual Studio(2010年)突出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一些C小练习的朋友,和我一直使用关键字从更新的语言(例如布尔,新的)出于习惯。我花了一段时间来实现,这是问题,因为VS保持彰显他们作为关键词,即使他们不是在C

I was doing some small exercises in C with a friend, and I kept using keywords from newer languages (e.g. bool, new) out of habit. It took me a while to realize that was the issue because VS kept highlighting them as keywords, even though they aren't in C.

我确信我的所有文件都的* .c,我设置了项目属性编译为C.然而,编辑总是除了C关键字添加语法highlightint为C ++关键字。有没有办法告诉Visual Studio中,我只是想简单的C?

I made sure all of my files were *.c, and I set the project properties to compile as C. However, the editor always added syntax highlightint for C++ keywords in addition to C keywords. Is there any way to tell Visual Studio that I just want plain C?

使用VS2010如果它很重要。

Using VS2010 if it matters.

推荐答案

您不能。 <一href=\"https://connect.microsoft.com/VisualStudio/feedback/details/516920/$p$pdefine-macro-problems\">This在Visual Studio中的已知的bug。的它用于在Visual Studio语法着色是基于微软收购了EDG C ++编译器的智能感知的机制,因为它们在Visual C / C ++编译器是适用于增量不佳解析需要处理不完整的code对即时分析。和EDG编译器是C ++只。

You cannot. This is a known bug in Visual Studio. The "Intellisense" mechanism which is used for syntax coloring in Visual Studio is based on the EDG C++ compiler which Microsoft bought, since their Visual C/C++ compiler is poorly suited for the incremental parsing required to handle on-the-fly analysis of incomplete code. And the EDG compiler is C++ only.

您可以看到通过创建编译为C.一个文件的foo.c这样的一个例子。然后添加到文件中以下行:

You can see an example of this by creating a foo.c file which compiles as C. Then add to the file the following lines:

 #ifdef __cplusplus
 #error C++ is what I am
 #else
 #error A bunch of C code!
 #endif

当您编译的程序,你会看到错误消息一帮C $ C $的c!但是,当你看Visual Studio编辑器窗口中,C面会显示为灰色和标记为非活动状态,只有C ++侧则是彩色的!这是因为智能感知语法colorer的基础上,EDG C ++编译器,认为这一切都是C ++。

When you compile your program you will see the error message "A bunch of C code!" But when you look at the Visual Studio editor window, the C side will be grayed out and marked inactive, and only the C++ side will be colored! That's because the Intellisense syntax colorer, based on the EDG C++ compiler, believes that everything is C++.

这篇关于如何获得C(不是C ++)语法在Visual Studio(2010年)突出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆