# Fix for compilation with gcc \>=4.5

**URL:** <https://discourse.radiance-online.org/t/fix-for-compilation-with-gcc-4-5/961>\
**Category:** radiance-dev\
**Created:** [February 18, 2011, 4:59pm UTC](https://discourse.radiance-online.org/t/fix-for-compilation-with-gcc-4-5/961 "2011-02-18T16:59:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bernd\_Zeimetz](https://discourse.radiance-online.org/letter_avatar_proxy/v4/letter/b/8491ac/32.png) [@Bernd\_Zeimetz](https://discourse.radiance-online.org/u/Bernd_Zeimetz)\
**Post date:** [February 18, 2011, 4:59pm UTC](https://discourse.radiance-online.org/t/fix-for-compilation-with-gcc-4-5/961/1 "2011-02-18T16:59:04Z")

</div>

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](https://discourse.radiance-online.org/uploads/default/original/1X/dccc1517443e7b2d66ee4e7032a1a447b5b577c2.5-fixes) (309 Bytes)

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

---

<div class="post-metadata">

**Author:** ![Greg\_Ward](https://discourse.radiance-online.org/user_avatar/discourse.radiance-online.org/greg_ward/32/471_2.png) [@Greg\_Ward](https://discourse.radiance-online.org/u/Greg_Ward)\
**Post date:** [February 18, 2011, 5:32pm UTC](https://discourse.radiance-online.org/t/fix-for-compilation-with-gcc-4-5/961/2 "2011-02-18T17:32:05Z")

</div>

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

Cheers,  
-Greg

> **···**
>
> > From: Bernd Zeimetz \<bernd@bzed.de\>  
> > 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://bzed.de)[http://www.debian.org](http://www.debian.org)  
> > GPG Fingerprint: ECA1 E3F2 8E11 2432 D485 DD95 EB36 171A 6FF9 435F

---

<div class="post-metadata">

**Author:** ![R\_Fritz1](https://discourse.radiance-online.org/letter_avatar_proxy/v4/letter/r/b3f665/32.png) [@R\_Fritz1](https://discourse.radiance-online.org/u/R_Fritz1)\
**Post date:** [February 19, 2011, 1:12am UTC](https://discourse.radiance-online.org/t/fix-for-compilation-with-gcc-4-5/961/3 "2011-02-19T01:12:40Z")

</div>

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 • RFritz@lbl.gov  
> Environmental Energy Technologies Division • Lawrence Berkeley Labs
