【发布时间】:2016-08-23 17:52:10
【问题描述】:
我正在运行 indent 和参数 -npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cp1,除了两个障碍之外一切都很好:
1) 在mytype_t * my; 之类的语句中,它倾向于在* 之后放置一个额外的空格,即
void my_function(my_type *ptr)
变成
void my_function(my_type * ptr)
2) 在(uint16_t *) & q->drops 等表达式中,它会在& 符号之后放置额外的空格,即
stats->drops = (uint16_t *) &q->drops
变成
stats->drops = (uint16_t *) & q->drops
运行indent 和-nss 或不使用-ss 都不能解决问题。
有没有办法告诉indent 不要这样做?如果没有,indent 的替代品是什么?
谢谢。
解决方案
% indent -T my_type -T uint16_t
【问题讨论】:
-
我不明白第二种情况。是不是少了什么东西?
-
旁注:8 个字符的缩进不是一个好主意。典型值为 2 到 4 个空格(4 个最常见)。 8 个空格会降低代码的可读性。
-
(uint16_t *) &->drops无论如何都不是有效的语法。 -
你能用
indent之前和之后的这些语句展示一个有效C源代码的例子(简短的)吗? -
@Eugene Sh.,我更新了原帖。
标签: c coding-style indentation gnu-indent