具有C / C ++预处理器支持的编辑器 [英] Editor with C/C++ preprocessor support

查看:63
本文介绍了具有C / C ++预处理器支持的编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



是否有任何支持语法高亮的C代码编辑器(不是VS),具体取决于(常见的)预处理器指令,例如:如果我有一个#ifdef bla foo #endif,并且文件中的bla不是#defined,而文件中包含的任何文件中没有#defined,那么代码是灰色的吗?

Hello,

Is there any C-code editor (not VS) that support syntax highlighting depending on (common) preprocessor directives, e.g. if I have a #ifdef bla foo #endif, and bla is not #defined in the file, and not #defined in any of the files that is included in the file, then the code is for instance greyed out ?

推荐答案

#define 符号的问题在于有很多地方可以定义它们: #include 位于某个项目特定路径,项目设置本身,环境变量(间接)或命令行中的文件。这使得任何没有完整IDE功能的编辑器都很难正确地解释它们!更重要的是,项目设置通常以特定于IDE的文件/格式存储,因此特定代码编辑器是否适合查看代码取决于它是否能够解释您拥有的项目设置文件!



请注意,VisualStudio 2015社区版是免费的(需要注册),其下载可以配置为仅安装(和下载)相关的C / C ++部分,完全跳过扩展的.NET库!以前的版本还提供免费版本,但通常需要几GB才能下载和安装。我们所说的尺寸和时间大约是5-10倍!



当然,如果您正在查看的文件是从Visual Studio开始不是,那么使用上面建议的编辑器确实更容易也更好。
The problem with #define symbols is that there are so many places to define them: in #include files that are located in some project-specific path, in the project setting itself, in environment variables (indirectly), or on the command line. That makes it very hard for any editor short of full IDE-capabilities to correctly interpret them! More importantly, project settings are often stored in an IDE-specific file/format, so whether a specific code editor is suitable to view your code depends on its ability to interpret the project settings file that you have!

Note that VisualStudio 2015 Community edition is free (requires registration though) and its download can be configured to only install (and download) the relevant C/C++ parts, skipping the expansive .NET library entirely! Previous releases also provided free versions, but they're typically several GB to download and install. We're talking of a factor of about 5-10 in both size and time required!

Of course, if the files you're looking at are not from Visual Studio to start with, then it may indeed be easier and better to just use one of the editors suggested above.


我建​​议 Notepad ++ 支持很多语言,可以高度自定义并且有很多有用的插件。



如果你不知所措,你可以制定自己的突出显示规则。
I would recommand Notepad++ which supports a lot of languages, is high customizable and has a lot of useful plugins.

If you fizzle around you can develop own highlighting rules.


关于程序员的任何编辑器正在进行语法高亮显示。 />


但是,你想要它来评估 #defines ,我从来不需要这样的东西因为我知道我是什么我在做什么,为什么我的代码中有一些 #ifdef 。我有一个常见的用法是为不同的目标构建, #define 直接在命令行上给编译器。我想它打败了这个功能:)



我更喜欢知道只有真正的评论会被突出显示为评论而没有别的。



为了真正高效,你的编辑器几乎需要嵌入一个编译器来评估预处理器指令。



就个人而言,我使用的是UltraEdit,符合我的需要。
About any editor for programmer is doing syntax highlighting.

But there, you want it to evaluate #defines, I have never needed such a thing because I know What I am doing and why I have some #ifdef in my code. And I have a common usage that is to build for different targets and the #define are given to compiler directly on command line. I guess that it defeat this feature :)

And I prefer to know that only real comments are highlighted as comments and nothing else.

To be really efficient, your editor almost need to embed a compiler to evaluate the preprocessor directives.

Personally, I use UltraEdit, which fit my needs.


这篇关于具有C / C ++预处理器支持的编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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