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.
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
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.
Could be [bugs:#3121]. Still closely related.
Related
Bugs: #3121