Mail Archives: djgpp/2002/09/27/05:00:08
Wlodzimierz ABX Skiba <abx AT abx DOT art DOT pl> wrote:
> Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de> wrote in message news:<ammsir$l1m$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE>...
>> Wlodzimierz ABX Skiba <abx AT abx DOT art DOT pl> 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.
- Raw text -