Initializing structures
Fergus Henderson
fjh@cs.mu.oz.au
Thu Apr 12 09:00:00 GMT 2001
On 12-Apr-2001, Tim Josling <tej@melbpc.org.au> wrote:
> In COBOL, you can specify initial values at any level. Translated
> to C this would look like this.
>
> struct mystruct {
> int a;
> int b;
> int c;
> ];
>
> struct mystruct XXX = "AAABBBCCC";
>
> In my dealings with tree.c I have tried to implement this in a
> straighforward way by setting a char[] initial value to the
> structure but the code generation appears to just ignore this.
...
> Any better ideas?
How about using a union to declare XXX?
struct mystruct {
int a;
int b;
int c;
};
union {
char c[sizeof(struct mystruct)];
struct mystruct s;
} XXX = { "AAABBBCCC"; };
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: < http://www.cs.mu.oz.au/~fjh > | -- the last words of T. S. Garp.
More information about the Gcc
mailing list