Fix for compilation with gcc >=4.5

Hi,

building radiance fails with gcc >=4.5 with
rhdobj.c:221:15: error: storage size of 'neighlist' isn't constant

which is due to the fact that using a define like
#define NAZI ((int)(PI/2.*NALT+.5))
to define the size of an array is not allowed - gcc 4.5 implements various
details of the standard stricter than versions before.

Attached patch fixes that, not sure if it is the best way to handle it - I
didn't check if NAZI or NALT will be redfined somewhere. The issue should be
fixed in some way, though.

Cheers,

Bernd

gcc-4.5-fixes (309 Bytes)

···

--
Bernd Zeimetz Debian GNU/Linux Developer
http://bzed.de http://www.debian.org
GPG Fingerprint: ECA1 E3F2 8E11 2432 D485 DD95 EB36 171A 6FF9 435F

Thanks Bernd, easily fixed. (Unfortunate choice of constant name...)

Cheers,
-Greg

···

From: Bernd Zeimetz <[email protected]>
Date: February 18, 2011 8:59:04 AM PST

Hi,

building radiance fails with gcc >=4.5 with
rhdobj.c:221:15: error: storage size of 'neighlist' isn't constant

which is due to the fact that using a define like
#define NAZI ((int)(PI/2.*NALT+.5))
to define the size of an array is not allowed - gcc 4.5 implements various
details of the standard stricter than versions before.

Attached patch fixes that, not sure if it is the best way to handle it - I
didn't check if NAZI or NALT will be redfined somewhere. The issue should be
fixed in some way, though.

Cheers,

Bernd

--
Bernd Zeimetz Debian GNU/Linux Developer
http://bzed.de http://www.debian.org
GPG Fingerprint: ECA1 E3F2 8E11 2432 D485 DD95 EB36 171A 6FF9 435F

Interesting--I would have thought that was a constant, since the value can be calculated at compile time. But then, it is asking a lot of the compiler to provide results consistent at run and compile times in that case. In The Old Days, I suppose a compiler would have just cavalierly ignored the issue, in the same way compilers assume that computer arithmetic is associative and commutative.

Randolph

···

On 2011-02-18 08:59:04 -0800, Bernd Zeimetz said:

Hi,

building radiance fails with gcc >=4.5 with
rhdobj.c:221:15: error: storage size of 'neighlist' isn't constant

which is due to the fact that using a define like
#define NAZI ((int)(PI/2.*NALT+.5))
to define the size of an array is not allowed - gcc 4.5 implements various
details of the standard stricter than versions before.

Attached patch fixes that, not sure if it is the best way to handle it - I
didn't check if NAZI or NALT will be redfined somewhere. The issue should be
fixed in some way, though.

Cheers,

Bernd

--
Randolph M. Fritz • [email protected]
Environmental Energy Technologies Division • Lawrence Berkeley Labs