Operating System - Linux
1755032 Members
5271 Online
108828 Solutions
New Discussion юеВ

Automatic aggregate error when compiling esql-c

 
SOLVED
Go to solution
TMcB
Super Advisor

Automatic aggregate error when compiling esql-c

Hello,

We are having a problem compiling an esql-c program on HP-UX 11.11.(64-bit). This progam previously compiled OK on HP-UX 11.00 32-bit.

cc: "gmin2113.ec", line 130: error 1716: Automatic aggregate initialization is a
n ANSI feature.

It is complaining about the following line:

datetime year to second sql_last_rec;

The sql_last_rec variable has to be a datetime type (and not char) because it is reading a datetime type from our informix database.

The easy way to get around this would be to change the flag on the compilation from -Ac to -Aa and compile it as ansi C. However we have include files which are externally generated (which we can't change) and which definitely won't compile as -Aa.

Is there anyway around this?

Many thanks.

5 REPLIES 5
Steven Schweda
Honored Contributor
Solution

Re: Automatic aggregate error when compiling esql-c

It might help to see exactly what this stuff
expands into (that is, what, exactly is on
"gmin2113.ec", line 130), but ...

> Automatic aggregate initialization is an
> ANSI feature.

If you can find a way to stick a "static" in
there somewhere to make the troublesome
variable static instead of automatic, then
the complaint should disappear.

The last time I saw one of these was this:

(Bundled) cc: "unzip.c", line 886: error
1716: Automatic aggregate initialization is
an ANSI feature.

The required change was from:
uch test_buf[ 2] = { 'a', 'b' };
to:
static uch test_buf[ 2] = { 'a', 'b' };

Which was easy enough to do, but I had easy
access to the actual C code involved.


> However we have include files [...]

Shouldn't there be a magic #pragma to let you
fiddle with this stuff on the fly?
Dennis Handly
Acclaimed Contributor

Re: Automatic aggregate error when compiling esql-c

>The easy way to get around this would be to change the flag on the compilation from -Ac to -Aa and compile it as ANSI C.

Instead compile with -Ae, ANSI with extensions.

>we have include files which are externally generated (which we can't change) and which definitely won't compile as -Aa.

Why do you say that? There are very few K&R constructs that won't compile with -Ae. A list of errors would be helpful here.

>Steven: Shouldn't there be a magic #pragma to let you fiddle with this stuff on the fly?

Not that I know of. You shouldn't have K&R code because K&R isn't supported on IPF.
TMcB
Super Advisor

Re: Automatic aggregate error when compiling esql-c

Thanks to you both for replying to my problem.
I'm sorry I'm only getting back to you now.

Dennis - compiling with -Ae didn't work. There were lots of errors similar to -Ac.

Steven - adding in static solved my problem! I'm still not sure what automatic aggregation means though.

Thank you very much for your help.
Steven Schweda
Honored Contributor

Re: Automatic aggregate error when compiling esql-c

> I'm still not sure what automatic
> aggregation means though.

Neither am I, but "automatic aggregate
initialization" is what happens when you
initialize an automatic aggregate. That is,
when you specify initial values for an
aggregate (a structure, union, or array (as
in my example)), which is automatic, (not
"static"), that is, the storage for the
entity may be used for other purposes outside
the scope of its declaration.

In real life, the compiler can normally tell
the linker to set the initial values for a
static entity, but the compiler needs to
generate actual code to do the initialization
for an automatic entity, and the crippled
bundled C compiler in HP-UX may be willing
and able to do the first job, but is unable
(or unwilling) to do the second job (which
was my problem). Similarly, if you cripple
the extra-cost C compiler with enough of the
right options, you can apparently get the
same effect.

For more details, you could consult a C
language manual or Google.

Not being able to see any of your actual C
code makes it hard to say exactly what's true
in your case.
Dennis Handly
Acclaimed Contributor

Re: Automatic aggregate error when compiling esql-c

>compiling with -Ae didn't work. There were lots of errors similar to -Ac.

What were they?

>Steven: "automatic aggregate initialization" is what happens when you initialize an automatic aggregate.

That's correct. Initializing auto local variables. (Autos are locals and parms.)

>the compiler can normally tell the linker to set the initial values for a static entity,

Except in the case for C++ static initializers.