Menu

#3408 Missing line number when initialization needs curly braces

open
nobody
None
other
5
2022-06-01
2022-06-01
Under4Mhz
No

The following error is generated for the below code:

sdcc -mz80 ./curly_braces.c 
-:0: error 69: struct/union/array '': initialization needs curly braces

The problem is the line number for the problematic code is missing, which can make it difficult to find the error.

// GPL 2.0
#include <stdint.h>
#include <stdbool.h>

typedef struct { int8_t x; int8_t y; } maths_point_i8;

///< Change enemy direction
void EnemyDirection() {

    maths_point_i8 dirx = { 0, 0 };
    maths_point_i8 directionsy[1] = { dirx };
}
sdcc -v
SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/sm83/tlcs90/ez80_z80/z80n/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15/mos6502 4.2.2 #13490 (Linux)
published under GNU General Public License (GPL)

The same issue occurs in 4.1.

Discussion

  • Benedikt Freisen

    The implementation of [feature-requests:#562] would make this error message obsolete all together. With a bit of luck I will be able to work on that in the near future.

     

    Related

    Feature Requests: #562

  • Maarten Brock

    Maarten Brock - 2022-06-01

    Your example looks fully braced to me. I don't understand what braces SDCC is expecting.

    But I don't think that dirx is considered a valid constant for initialization of directionsy.
    I think SDCC is throwing the wrong error message.

     
    👍
    1
    • Benedikt Freisen

      Could be [bugs:#3121]. Still closely related.

       

      Related

      Bugs: #3121


Log in to post a comment.

MongoDB Logo MongoDB