我发现了一个 C 程序,作者在类型声明中在变量名之前添加了一个空格:
int * foo;
GNU 缩进总是删除这个空格,不管是什么风格(GNU、K&R、Linux)。我发现在任何地方都没有明确提到这个约定。除了“没人做”之外,我能告诉这个程序的作者什么?
我发现了一个 C 程序,作者在类型声明中在变量名之前添加了一个空格:
int * foo;
GNU 缩进总是删除这个空格,不管是什么风格(GNU、K&R、Linux)。我发现在任何地方都没有明确提到这个约定。除了“没人做”之外,我能告诉这个程序的作者什么?
There's justification for the style T *p;
- that's how the grammar works.
There's justification for the style T* p;
- it emphasizes that p
has pointer type.
There's no real justification for T * p;
other than it may look pretty to someone. Having said that, style is only an issue if it leads to confusion. If he's just declaring the one variable per line, then I don't think this is a problem. If he's writing something like
int * foo, bar;
then you might want to politely suggest he use the convention
int *foo, bar;
to make it clear that only foo
is being declared as a pointer.