Any C programmers awake?

I could use any help anyone could give for this. To write a piece of code, I need to strip out all the ANSI features (prototyping and whatnot). It is so I can use an HP-UNIX specific function or three. Anyway, I’m getting this error and I have no idea why:

error 1716: Automatic aggregate initialization is an ANSI feature.

It’s for a 2D array I have defined. What’s the problem and how do I fix it?

Thanks to all.

Oh, here is one of the arrays:

int m_d_array[MONTHS_IN_YEAR][MONTHS_IN_YEAR] =
{{ JANURARY, FEBRUARY, MARCH,
APRIL, MAY, JUNE,
JULY, AUGUST, SEPTEMBER,
OCTOBER, NOVEMBER, DECEMBER},
{ DAYS_IN_JANURARY, DAYS_IN_FEBRUARY,
DAYS_IN_MARCH, DAYS_IN_APRIL,
DAYS_IN_MAY, DAYS_IN_JUNE,
DAYS_IN_JULY, DAYS_IN_AUGUST,
DAYS_IN_SEPTEMBER, DAYS_IN_OCTOBER,
DAYS_IN_NOVEMBER, DAYS_IN_DECEMBER}};

It’s 12 by 12, and everything in it has a #define (the numbers used are sort of obvious.

Thanks again.

I’m more of a C++ guy (and lately, more of a TCL guy :)), but try making the array static:



 **static** int m_d_array[MONTHS_IN_YEAR][MONTHS_IN_YEAR] = 
{{ JANURARY, FEBRUARY, MARCH,
APRIL, MAY, JUNE, 
JULY, AUGUST, SEPTEMBER,
OCTOBER, NOVEMBER, DECEMBER},
{ DAYS_IN_JANURARY, DAYS_IN_FEBRUARY,
DAYS_IN_MARCH, DAYS_IN_APRIL,
DAYS_IN_MAY, DAYS_IN_JUNE,
DAYS_IN_JULY, DAYS_IN_AUGUST,
DAYS_IN_SEPTEMBER, DAYS_IN_OCTOBER,
DAYS_IN_NOVEMBER, DAYS_IN_DECEMBER}};


That may fix it. Then again, it may not.

who would have thought? maybe it was the static declaration space that fixed the problem. well… at least the error. thanks much. if anyone could tell me what that error actually meant, i would be most thankful.

And if you had been writing Perl, this would never have happened.

Let that be a lesson to you.

:smiley:

If a variable isn’t static then it’s automatic.
If it’s made up of pieces, like an array or struct, then it’s an aggregate.
If you’re specifying a value in the declaration then you’re initializing.
You can do this in ANSI but not in standard C.

“You can do this in ANSI but not in standard C”

ANSI/ISO 9899:1995 is standard C.

I don’t see what oddball compiler CAN’T compile ISO 9899 code!

ISO C is the way to go.

I don’t know why static vs non-static makes a difference, but I do know you have a much more blatant error: that’s not a 12x12 array. It’s a 2x12 array.

You also spelled “January” wrong. If DAYS_IN_JANURARY is defined elsewhere in your program and spelled differently, this may be a major problem.

Bryan Ekers - not to worry, i’m a consistantly bad speller.

Yeah, but Perl lets you screw up in new and interesting ways. :wink: