This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Silly brackets (Was: Re: Problems extending Python with C.)


> I would not think it is a problem, as #define's all expand into one line,
> and there is nothing to report about brackets which match on the same line.
> Could you provide an example of pre-processor breaking user indentation?

It depends on the exact rules you impose. Consider

#define foo(x)         x
int main()
{
  bar();
  foo(4);
}

After preprocessor, I get

# 1 "a.c"

int main()
{
  bar();
   4  ;
}

In the Python sense of indentation, the second line is not aligned
with the previous one, so it is incorrectly indented.

Suppose you'd implement such a feature: How exactly would you define
'correct indentation'? Probably you'd consider the position of the
closing bracket. Must that be

a) in the same column as the opening one?
b) aligned with the keyword starting the block?

Would you check anything else? I.e. what magic would find the
often-quoted

  for (i=0;i<10;i++);
    printf("%d\n",i);

Regards,
Martin

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]