This is perfectly fine for me -- add curly braces around
each struct initializer and you are done.
I guess your code is non-valid ANSI C code (according do a
draft of the standard, struct and union initializers must be
brace-enclosed (6.7.8:16)).
Can anyone confirm this?
Fixed code:
struct {
int a;
int b;
} astruc[] = {
{1, 1},
{2, 2}
};
void main(void)
{
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've always kept my old copy of K&R as my C reference
standard. However, if it compiles (confirmed) with extra
braces (whether standard or not) I'm happy. Thanks for the
quick turn-around.
Jim Cramer
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Allthough I don't have my copy of C99 at hand right now, I
know SDCC does not support initialization without the extra
braces. Using them however makes so much clearer code
and it definitely is according to the standard.
And there are more things in K&R that SDCC does not
support, like:
foo()
int a;
{...}
to declare parameter a.
I don't think we have any intention on changing that.
Greets,
Maarten
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Logged In: YES
user_id=1115835
SDCC output:
init.c:4: error 69: struct/union/array 'astruc'
:initialization needs curly braces
This is perfectly fine for me -- add curly braces around
each struct initializer and you are done.
I guess your code is non-valid ANSI C code (according do a
draft of the standard, struct and union initializers must be
brace-enclosed (6.7.8:16)).
Can anyone confirm this?
Fixed code:
struct {
int a;
int b;
} astruc[] = {
{1, 1},
{2, 2}
};
void main(void)
{
}
Logged In: NO
I've always kept my old copy of K&R as my C reference
standard. However, if it compiles (confirmed) with extra
braces (whether standard or not) I'm happy. Thanks for the
quick turn-around.
Jim Cramer
Logged In: YES
user_id=888171
Jim,
Allthough I don't have my copy of C99 at hand right now, I
know SDCC does not support initialization without the extra
braces. Using them however makes so much clearer code
and it definitely is according to the standard.
And there are more things in K&R that SDCC does not
support, like:
foo()
int a;
{...}
to declare parameter a.
I don't think we have any intention on changing that.
Greets,
Maarten