From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp Subject: Re: cleaning source from warnings troubles Date: 27 Sep 2002 08:59:05 GMT Organization: Aachen University of Technology (RWTH) Lines: 54 Message-ID: References: NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 1033117145 23066 137.226.32.75 (27 Sep 2002 08:59:05 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 27 Sep 2002 08:59:05 GMT Originator: broeker@ To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Wlodzimierz ABX Skiba wrote: > Hans-Bernhard Broeker wrote in message news:... >> Wlodzimierz ABX Skiba wrote: >> >> > 1. "aggregate has a partly bracketed initializer" >> [...] >> >> I can't see any particular reason for this one. Are you sure you >> quoted the actual source fragment this warning was about? > Yes. This structure contains 20 entries and warning is outputed 20 > times. Number of line in warning point to line with closing bracket of > this structure. Hmm.. yes, on second look, I think I see what this is about. You have a an array of structs, where the struct's only element is an array. Strictly speaking that's two aggregates inside each other, so you would need *two* pairs of {} per struct. I.e the layout should be typedef struct foo { int bar[4]; } foo; foo baz[20] = { { { 0, 1, 2, 3} }, { { 4, 5, 6, 7} }, /* ... */ { { 76, 77, 78, 79} } }; > But this is written in so called "portable" package - POV-Ray. Well -- it's not all that portable as it thinks it is, then. As I stated, this code is firmly in the "implementation defined" region, and thus not truly portable C. > Any other way to write this part as more portable code ? Yet another enum, or a special macro to take 4 chars and transform them into an int, which I think the coders were assuming this code would do for them: #define FOURCHARS_TO_INT(c1,c2,c3,c4) \ (((unsigned long) c1 << 24) \ || ((unsigned long) c2 << 16) \ || ((unsigned long) c3 << 8) \ || (unsigned long) c4) -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.