我正在使用参数-npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cp1 ,除了两个障碍外,一切都很好:
1)在mytype_t * my;类的语句中,它往往会在*后添加一个额外的空格mytype_t * my; ,即
void my_function(my_type *ptr)变成
void my_function(my_type * ptr)2)它在&符号之后放置额外的空格,如(uint16_t *) & q->drops ie
stats->drops = (uint16_t *) &q->drops变成
stats->drops = (uint16_t *) & q->drops使用-nss或不使用-ss运行indent不能解决问题。
有没有办法告诉indent不要这样做? 如果没有, indent的替代方法是什么?
谢谢。
解
% indent -T my_type -T uint16_tI'm running indent with arguments -npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cp1, all is good except two obstacles:
1) It tends to put an extra space after * in statements like mytype_t * my;, i.e.
void my_function(my_type *ptr)turns into
void my_function(my_type * ptr)2) It places extra space after & symbol in expressions like (uint16_t *) & q->drops i.e.
stats->drops = (uint16_t *) &q->dropsturns into
stats->drops = (uint16_t *) & q->dropsRunning indent with -nss or without -ss does not solve the problem.
Is there a way to tell indent not to do this? If not, what are the alternatives to indent ?
Thanks.
SOLUTION
% indent -T my_type -T uint16_t最满意答案
从man indent :
您必须使用'-T'选项告诉缩进程序中由typedef定义的所有类型名称。 '-T'可以多次指定,并且使用指定的所有名称。 例如,如果您的程序包含
typedef unsigned long CODE_ADDR; typedef enum {red, blue, green} COLOR;
你会使用选项-T CODE_ADDR -T COLOR 。
所以似乎indent不知道stdint.h类型,所以你必须通过传递-T uint16_t -T mytype_t让它知道你正在使用它们
From man indent:
You must use the '-T' option to tell indent the name of all the typenames in your program that are defined by typedef. '-T' can be specified more than once, and all names specified are used. For example, if your program contains
typedef unsigned long CODE_ADDR; typedef enum {red, blue, green} COLOR;
you would use the options -T CODE_ADDR -T COLOR.
So it seems like indent doesn't know about the stdint.h types, so you have to let it know you are using them by passing -T uint16_t -T mytype_t
更多推荐
发布评论