Skip to content

How to control a designated initializer list alignment (C lang)? #967

Open

Description

@adel-mamin

Hi,
I am running 0.64_d version here.
Is there a way to control the alignment of the designated initialization list?
Here is an example:
https://bitbucket.org/adel-mamin/uncrustify-test.git
My original file is in.c. What I get after running uncrustify is in out.c
You can see that it removes the manually added alignment of the initialization list.
I want it to be like in the in.c file. So how to control it?
Thanks!

Activity

  1. mihaipopescu commented on Jan 27, 2017

    @mihaipopescu
    Collaborator

    That's a very good question. I suspect that uncrustify doesn't really support C99 designated initializers. Actually I'm not sure if all compilers do (at least non-trivial ones)...

  2. guy-maurel commented on May 3, 2017

    @guy-maurel
    Contributor

    Please push a configuration file with only the important options

  3. adel-mamin commented on Aug 13, 2017

    @adel-mamin
    Author

    The example configuration file can be found behind the link above. The problem is that uncrustify does not seem to allow control of alignment of C99 designated initializers. I am not quite sure I understand what is meant by important options here.

  4. guy-maurel commented on Jun 4, 2018

    @guy-maurel
    Contributor

    The problem is having a struct initializer inside a struct initializer inside something.
    uncrustify can't yet deal with that.
    The output are not predictable.

    Related to #1293, #1349, #1601, #1727

  5. nikiwaibel commented on Mar 5, 2019

    @nikiwaibel

    i just wrote this code …

    mytype_t myType = {
            .header = {
                    .version = 1,
                    .v1 = {
                            .n = 5,
                    },
            },
            .data = {
                    { 3300, 1, 0x0000 }, { 3300, 2, 0x0000 },
                    { 4400, 1, 0xbfff }, { 4400, 2, 0xffff },
                    { 5500, 4, 0x0000 },
            },
    };

    … and had to use /* *INDENT-OFF* */ and /* *INDENT-ON* */ 🤔

  6. guy-maurel commented on Apr 4, 2019

    @guy-maurel
    Contributor

    The problem is having a struct initializer inside a struct initializer inside something.
    uncrustify can't yet deal with that.
    The output are not predictable.

    Related to #967, #1293, #1349, #1601, #1727, #1848

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions