Menu

#562 Support free forms of array initialization

None
open
nobody
None
5
2021-02-02
2015-05-24
Ben Shi
No

The follow c code is accepted by gcc, while sdcc complaints it.

int asd[][4] = {1,2, 28,33,3};
int www[][2][3] = {1,2,3,4,5,6,7};

Related

Bugs: #3408
Wiki: NGI0-Commons-SDCC
Wiki: SDCC-STD-UX

Discussion

  • Ben Shi

    Ben Shi - 2015-07-10

    A more complex case is

    struct ss {
    int buf[4];
    int len;
    };

    struct ss q[][3] = {{1, 2}, {3, 4, 5, 6}, 7, 9, 0, 1};

    GCC can accept it, but I can not figure how to handle it in SDCC.

     
  • Philipp Klaus Krause

    Ticket moved from /p/sdcc/bugs/2387/

    Can't be converted:

    • _category: Front-end
     
  • Benedikt Freisen

    I think it's best to add the required functionality to the reorderIlist function in SDCCval.c or to rewrite it accordingly.
    It basically has to keep track of the type of the ilist elements it iterates over and move parts of the ilist to nested ilists if the type indicates an aggregate type but the ilist is not deep.

    This has to take the special case from [bugs:#3121] into account, too. It is about a struct variable in an initializer list.

     

    Related

    Bugs: #3121


    Last edit: Benedikt Freisen 2021-02-07

Log in to post a comment.

MongoDB Logo MongoDB