[Bf-committers] Casting arrays (matrices)

Ton Roosendaal bf-committers@blender.org
Wed, 2 Jul 2003 22:32:33 +0200


It caused warnings in compiling at osx and other unices. Loads and  
loads of them! I don't know how it compiled well at NaN...

The commits go to bf-blender-cvs maillist, there I wrote some more info:

   Modified files:
     blender/source/blender/blenlib BLI_arithb.h
     blender/source/blender/blenlib/intern arithb.c

   - removed the 'const' from arithb function declarations. it caused
     the myriad of warnings people complained about so long.

     after careful consulting & reading I could not find a good reason
     for this const stuff, apart from a sort-of comment to indicate
     this array (matrix) pointer cannot be changed. Well, doh! you
     should not do that with a float mat[][3] anyway!

I can imagine it is useful to add 'const' in a function as some  
information for other users. But doing it here, in basic matrix  
calculus calls, is just over the top. Especially when it generates  


On Wednesday, Jul 2, 2003, at 22:07 Europe/Amsterdam, Maarten Gribnau  

> Hi Ton
>> Reading the arithb.c code, I found that someone (NaN) has included a  
>> lot of 'const' variables in the function declarations. I have  
>> absolutely no clue what it's good for. Originally, the code worked  
>> fine without, as still is in the MTC_matrixops.c version in  
>> source/blender/blenlib/
>> I've removed the 'const' everywhere from arithb.c. The code compiles  
>> quite a lot faster, with only a few and more useful warnings left.
> How does the const cause trouble?
> The const is actually useful. It tells you the function is not going  
> to modify the variable (usually pointers and references in C++) passed  
> to it. It makes the variable an "in only" variable.
> Maarten
> _______________________________________________
> Bf-committers mailing list
> Bf-committers@blender.org
> http://www.blender.org/mailman/listinfo/bf-committers
Ton Roosendaal  Blender Foundation ton@blender.org