inst182@tuvie (Inst.f.Techn.Informatik) (01/04/90)
Th Apollo C Compiler seems to have problems when initializing typedef'd
structures. This is especialliy disturbing when compiling X-programs,
since initializing structures becomes virtually impossible.
Has anybody had a similar problem and found a solution ?
Michael K. Gschwind ...!uunet!mcsun!tuvie!vlsivie!gschwind
--------------------------------------------------------------------------------
/*
* SCCS ID : @(#)xpclock.h 1.2 11/1/89
*
* xpclock.h - Header for Pendulum Clock for X11
*
* Author: Kazuhiko Shutoh, 1989.
*
* Permission to use, copy, modify and distribute without charge this software,
* documentation, images, etc. is granted, provided that this comment and the
* author's name is retained. The author assumes no responsibility for lost
* sleep as a consequence of use of this software.
*
* Send any comments, bug reports, etc. to: shutoh@isl.yamaha.co.jp or, for
* oversea: shutoh%isl.yamaha.co.jp%kddlab@uunet.uu.net
*
*/
#define PI 3.141592654
#define ON 1
#define OFF 0
#define CLOCKFACE_UPDATE 5000
/* Number vector :-) fonts */
typedef struct {
double x1;
double y1;
double x2;
double y2;
} NumberSegment;
typedef struct {
NumberSegment segment[5];
} NumberSegmentRec;
NumberSegmentRec num_segments[12] = {
{
{0, 0, 0, 2}, /* 1 */
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0}
},
{
{0, 0, 0, 2}, /* 2 */
{1, 0, 1, 2},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0}
},
{
{0, 0, 0, 2}, /* 3 */
{1, 0, 1, 2},
{2, 0, 2, 2},
{0, 0, 0, 0},
{0, 0, 0, 0}
},
{
{0, 0, 0, 2}, /* 4 */
{1, 0, 1.5, 2},
{1.5, 2, 2, 0},
{0, 0, 0, 0},
{0, 0, 0, 0}
},
{
{0, 0, 0.5, 2}, /* 5 */
{0.5, 2, 1, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0}
},
{
{0, 0, 0.5, 2}, /* 6 */
{0.5, 2, 1, 0},
{2, 0, 2, 2},
{0, 0, 0, 0},
{0, 0, 0, 0}
},
{
{0, 0, 0.5, 2}, /* 7 */
{0.5, 2, 1, 0},
{2, 0, 2, 2},
{3, 0, 3, 2},
{0, 0, 0, 0}
},
{
{0, 0, 0.5, 2}, /* 8 */
{0.5, 2, 1, 0},
{2, 0, 2, 2},
{3, 0, 3, 2},
{4, 0, 4, 2}
},
{
{0, 0, 0, 2}, /* 9 */
{1, 0, 2, 2},
{2, 0, 1, 2},
{0, 0, 0, 0},
{0, 0, 0, 0}
},
{
{0, 0, 1, 2}, /* 10 */
{0, 2, 1, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0}
},
{
{0, 0, 1, 2}, /* 11 */
{0, 2, 1, 0},
{2, 0, 2, 2},
{0, 0, 0, 0},
{0, 0, 0, 0}
},
{
{0, 0, 1, 2}, /* 12 */
{0, 2, 1, 0},
{2, 0, 2, 2},
{3, 0, 3, 2},
{0, 0, 0, 0}
}
};
/* Resource for Clock Widget */
static XrmOptionDescRec options[] = {
{"-chime", "*clock.chime", XrmoptionNoArg, "TRUE"},
{"-hd", "*clock.hands", XrmoptionSepArg, NULL},
{"-hands", "*clock.hands", XrmoptionSepArg, NULL},
{"-hl", "*clock.highlight", XrmoptionSepArg, NULL},
{"-highlight", "*clock.highlight", XrmoptionSepArg, NULL},
{"-update", "*clock.update", XrmoptionSepArg, NULL},
{"-padding", "*clock.padding", XrmoptionSepArg, NULL},
{"-d", "*clock.analog", XrmoptionNoArg, "FALSE"},
{"-digital", "*clock.analog", XrmoptionNoArg, "FALSE"},
{"-analog", "*clock.analog", XrmoptionNoArg, "TRUE"},
};
--------------------------------------------------------------------------------vasta@apollo.HP.COM (John Vasta) (01/05/90)
In article <1047@tuvie> inst182@tuvie (Inst.f.Techn.Informatik) writes: > > >Th Apollo C Compiler seems to have problems when initializing typedef'd >structures. This is especialliy disturbing when compiling X-programs, >since initializing structures becomes virtually impossible. > >Has anybody had a similar problem and found a solution ? > > Michael K. Gschwind ...!uunet!mcsun!tuvie!vlsivie!gschwind The code contains an incorrectly structured initialization list. The aggregate being initialized has four levels of structure, but the initialization list contains only three. C allows you to elide braces for the innermost level of an aggregate, but it appears that the author had elided them for the next-innermost level. The initializer list should look like this: NumberSegmentRec num_segments[12] = { { { /* this was added by me */ {0, 0, 0, 2}, /* 1 */ {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} } /* so was this */ }, ... By the way, the AT&T 2.0 C++ translator and the GNU C compiler also complain about this code, so the Apollo C compiler is not the only one which diagnoses this error. John Vasta Apollo Computer (division of Hewlett-Packard) vasta@apollo.hp.com M.S. CHA-01-LT (508) 256-6600 x6362 330 Billerica Road, Chelmsford, MA 01824 UUCP: {decwrl!decvax, mit-eddie, attunix}!apollo!vasta