缩进C预处理程序指令

编程入门 行业动态 更新时间:2024-10-22 11:35:57
本文介绍了缩进C预处理程序指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

任何人都可以推荐一个程序来缩进C预处理器 指令。我的文件看起来像这样: #ifdef a #define b #else #define c #endif int main() { 返回0; } 我想要一个程序能够自动缩进预处理器 指令。 我已经尝试过astyle ,但没有成功。 Bogdan

解决方案

Bogdan写道:

任何人都可以推荐一个程序来缩进C预处理器 指令。我的文件看起来像这样: #ifdef a #define b #else #define c #endif int main() { 返回0; } 我想要一个程序能够自动缩进预处理器 指令。 我已经尝试过astyle但是没有成功。

缩进(1)和vim都说你提供的来源已经很好地缩进了 ... 如果您想要的是类似的东西 #ifdef a #define b #else #define c #endif ,那我觉得你''我的习惯很不寻常......

Bogdan

- Pietro Cerutti PGP公钥: gahr.ch/pgp

2007年5月21日,Pietro Cerutti< ga ** @ gahr.chwrote:

Bogdan写道: >任何人都可以推荐一个程序来缩进C预处理程序指令。我的文件看起来像这样: #ifdef a #define b #else #define c #endif int main( ) {返回0; } 我想要一个程序能够自动缩进预处理器指令。 我已经尝试了astyle,但没有成功。

缩进(1)和vim都说你提供的来源已经是 缩进了好方法... 如果您想要的是类似的东西 #ifdef a #定义b #else #define c #endif ,那么我想你'有一个不寻常的习惯......

也许不寻常,但至少*我不再感到如此孤独; - ) 我觉得有些编译器很久以前就不支持预处理器 指令#除了第一列以外的其他指令,但没有我支持在过去的几年中使用的有这个资源triction。说真的,不是缩进的子句版本*方式*更容易阅读?如果我们缩进如果 条款,为什么我们不能因为同样的原因缩进#if条款? BTW,我不会使用单独的程序。我的编辑器使用它的自动功能处理大部分 。 Dave - - David Tiktin tiktin [at] advancedrelay [dot] com

David Tiktin写道:

> 2007年5月21日,Pietro Cerutti< ga ** @ gahr.chwrote:

Bogdan写道:

任何人都可以推荐一个程序来缩进C预处理器 指令。我的文件看起来像这样: #ifdef a #define b #else #define c #endif

[...]

我希望程序能够自动缩进预处理器 指令。

[...]

如果你想要的东西类似于这个 #ifdef a #define b #else #define c #endif ,那么我觉得你有一个不寻常的习惯......

也许不寻常,但至少*我不再感到如此孤独;-) 我认为一些编译器很长之前没有支持预处理器 指令与第一列中的#以外的其他指令,但是在过去几年里我没有使用过指令。

我看过程序在第一列中保留''#'',并在它和指令之间插入 空格。 (标准是否允许这是允许的吗?)使用相同的例子: #ifdef a #define b #else #define c #endif

说真的,isn '缩进的子句版本*方式*更容易阅读? 如果我们缩进if子句,为什么我们不能缩进#if子句为 同样的原因?

当你有复杂的嵌套#if / #ifdef'时,对我来说肯定更容易 。但是,我编程的时间足够长,以至于我已经使用了第1列中需要''#'的编译器,并且没有空白 跟着它所以我养成了不缩进这些东西的习惯。 如果标准保证上述两种情况之一,我可能会自行重新培训。 [...] - + -------------- ----------- + -------------------- + ----------------- ------ + | Kenneth J. Brody | www.hvcomputer | #include | | kenbrody / at\spamcop | www.fptech | < std_disclaimer.h | + ------------------------- + --------- ----------- + ----------------------- + 不要 - 邮寄给我:< mailto:Th ************* @ gmail>

Can anyone recommend a program for indentation of C preprocessor directives. My file looks like this: #ifdef a #define b #else #define c #endif int main() { return 0; } and I want a program able to automatically indent the preprocessor directives. I have already tried astyle, but with no success. Bogdan

解决方案

Bogdan wrote:

Can anyone recommend a program for indentation of C preprocessor directives. My file looks like this: #ifdef a #define b #else #define c #endif int main() { return 0; } and I want a program able to automatically indent the preprocessor directives. I have already tried astyle, but with no success.

indent(1) and vim both say that the source you provided is already indented in a good way... If what you want is something similar to this #ifdef a #define b #else #define c #endif , then I think you''ve got quite an unusual habit...

Bogdan

-- Pietro Cerutti PGP Public Key: gahr.ch/pgp

On 21 May 2007, Pietro Cerutti <ga**@gahr.chwrote:

Bogdan wrote:

>Can anyone recommend a program for indentation of C preprocessordirectives. My file looks like this:#ifdef a#define b#else#define c#endifint main(){ return 0;}and I want a program able to automatically indent the preprocessordirectives.I have already tried astyle, but with no success.

indent(1) and vim both say that the source you provided is already indented in a good way... If what you want is something similar to this #ifdef a #define b #else #define c #endif , then I think you''ve got quite an unusual habit...

Maybe unusual, but at least *I* don''t feel so lonely anymore ;-) I think some compilers long ago didn''t support preprocessor directives with the # other than in the first column, but none I''ve used in that past few years have that restriction. Seriously, isn''t the indented clause version *way* easier to read? If we indent if clauses, why shouldn''t we indent #if clauses for the same reason? BTW, I don''t use a separate program for this. My editor handles most of it for me with it''s autoindent feature. Dave -- D.a.v.i.d T.i.k.t.i.n t.i.k.t.i.n [at] a.d.v.a.n.c.e.d.r.e.l.a.y [dot] c.o.m

David Tiktin wrote:

> On 21 May 2007, Pietro Cerutti <ga**@gahr.chwrote:

Bogdan wrote:

Can anyone recommend a program for indentation of C preprocessor directives. My file looks like this: #ifdef a #define b #else #define c #endif

[...]

and I want a program able to automatically indent the preprocessor directives.

[...]

If what you want is something similar to this #ifdef a #define b #else #define c #endif , then I think you''ve got quite an unusual habit...

Maybe unusual, but at least *I* don''t feel so lonely anymore ;-) I think some compilers long ago didn''t support preprocessor directives with the # other than in the first column, but none I''ve used in that past few years have that restriction.

I''ve seen programs keep the ''#'' in the first column, and insert whitespace between it and the directive. (Does the Standard say that this is allowed?) Using the same example: #ifdef a # define b #else # define c #endif

Seriously, isn''t the indented clause version *way* easier to read? If we indent if clauses, why shouldn''t we indent #if clauses for the same reason?

When you have complex nested #if/#ifdef''s, it is certainly easier to read for me. However, I''ve been programming long enough that I''ve used compilers that required the ''#'' in column 1, and no whitespace following it, so I got in the habit of not indenting such things. If the Standard guarantees both/either of the above, I just may retrain myself. [...] -- +-------------------------+--------------------+-----------------------+ | Kenneth J. Brody | www.hvcomputer | #include | | kenbrody/at\spamcop | www.fptech | <std_disclaimer.h| +-------------------------+--------------------+-----------------------+ Don''t e-mail me at: <mailto:Th*************@gmail>

更多推荐

缩进C预处理程序指令

本文发布于:2023-11-14 00:40:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1585747.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:指令   程序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!