emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C99 compound literals in c-mode


From: Helmut Eller
Subject: Re: C99 compound literals in c-mode
Date: Tue, 15 Aug 2017 11:57:17 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

On Tue, Aug 15 2017, Stefan Monnier wrote:

>> C-mode doesn’t seem to understand C99’s compound literals, resulting in
>> rather broken indentation.  Is this correct and, if so, how difficult would
>> it be to add support for it?
>
> Could you show some example problematic code?

I think code like this:

int foo (void)
{
  return (struct bar) { .f1 = 10,
                         .f2 = 20,
                         };
}

should be indented better.  Maybe so:

  return (struct bar) { .f1 = 10,
                        .f2 = 20,
                      };

There are also strange interactions with declarations, eg. adding a
a declaration before the return changes the indentation to:

int foo (void)
{
  int i = 1;
  return (struct bar) { .f1 = 10,
      .f2 = 20,
      };
}

Helmut




reply via email to

[Prev in Thread] Current Thread [Next in Thread]