delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/09/27/05:00:08

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
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: <an16kp$mgq$1@nets3.rz.RWTH-Aachen.DE>
References: <e8982227 DOT 0209230144 DOT 2d26793e AT posting DOT google DOT com> <ammsir$l1m$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <e8982227 DOT 0209270013 DOT 38800e2f AT posting DOT google DOT com>
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 <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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019