[csw-maintainers] initialization problem: struct + union

Philip Brown phil at bolthole.com
Fri Jun 3 23:53:46 CEST 2011


Hitting a problem trying to get something to compile with sun cc.
problem is auto-definition of a struct that has a union in it.
I forget what the hack is, to get sun cc to accept this sort of thing :(

A chopped down version, which compiles with gcc, but fails under sun cc:
( complains about the    {integer:2}  thing at bottom)




#include <stdio.h>
union types {
  char *string;
  int integer;
};
typedef struct {
  char *option;
  int type;
  union types default_value;
} config_opt_t;

#define INTEGER 1

config_opt_t config_opts[] = {
  { "snmp_timeout", INTEGER, {integer:2} },
};


More information about the maintainers mailing list