[Bf-committers] Casting arrays (matrices)

Douglas Toltzman bf-committers@blender.org
Thu, 3 Jul 2003 12:01:27 -0400 (EDT)

If you're using a C++ compiler (with name mangling) the prototype must
match the function, including const modifiers.  However, I don't think
anyone was arguing that point.  I for one, was not advocating a mismatch
between prototypes and functions.  I was advocating the use of compiler
features to document and enforce expected behavior.  This is especially
important when you're working on a large project and there are multiple
teams working on different modules.  Although, as Ton pointed out, the
syntax can get hairy and some compilers don't handle some constructs as
well as others, conceptually, it's always a good idea to let the compiler
do as much type checking as possible.  I think that is all Maarten and
I were saying.

Douglas Toltzman

On Thu, 3 Jul 2003, Philipp [iso-8859-1]
G=FChring wrote:

> Hash: SHA1
> Hi,
> > > I'm with Maarten on this one.  If I gave you a prototype for a string
> > > copy
> > > function that read "strcyp(char *target,const char *source)" it would
> > > not
> > > only tell you that your source string wouldn't be modified, but it
> > > would
> > > allow the compiler to enforce that behavior.
> ;-)
> The compiler: yes.=20
> The linker: no!
> Just create your own header files without const, compile against your own=
> header files, and link against the const library.
> I know that because it was necessary to do that with a closed-source libr=
> Please use const only when you are absolutely sure that nobody ever could=
> have any use of modifying it. Otherwise you create a Denial-of-Service!
> And please avoid const when you design callback interfaces.
> Many greetings,
> - --=20
> ~ Philipp G=FChring              p.guehring@futureware.at
> ~ http://www.livingxml.net/       ICQ UIN: 6588261
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: For info see http://www.gnupg.org
> iD8DBQE/A3ONlqQ+F+0wB3oRAk+WAJ4nSPECzidU2z3FTwBFrIEv8Nbs+ACgs1ep
> Txr+tbm5T2r+7jLhQgr5tJY=3D
> =3D+cyt