[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:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>=20
> Hi,
>=20
> > > 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.
>=20
> ;-)
>=20
> The compiler: yes.=20
> The linker: no!
>=20
> Just create your own header files without const, compile against your own=
=20
> header files, and link against the const library.
>=20
> I know that because it was necessary to do that with a closed-source libr=
ary.
>=20
> Please use const only when you are absolutely sure that nobody ever could=
=20
> have any use of modifying it. Otherwise you create a Denial-of-Service!
>=20
> And please avoid const when you design callback interfaces.
>=20
> Many greetings,
> - --=20
> ~ Philipp G=FChring              p.guehring@futureware.at
> ~ http://www.livingxml.net/       ICQ UIN: 6588261
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: For info see http://www.gnupg.org
>=20
> iD8DBQE/A3ONlqQ+F+0wB3oRAk+WAJ4nSPECzidU2z3FTwBFrIEv8Nbs+ACgs1ep
> Txr+tbm5T2r+7jLhQgr5tJY=3D
> =3D+cyt
> -----END PGP SIGNATURE-----