[Developers] Const correctness for cGH *

Erik Schnetter schnetter at aei.mpg.de
Sun Jun 5 13:35:35 CDT 2005


In the languages C and C++, the macro CCTK_ARGUMENTS currently expands 
to

	cGH *

allowing people to modify the cGH structure.  (Few thorns do, e.g. Time 
sets the CFL factor.)  At the same time, we have many prototypes such 
as

CCTK_INT FUNCTION Coord_SystemRegister  \
  (CCTK_POINTER_TO_CONST IN GH,         \
   CCTK_INT IN dim,                     \
   CCTK_STRING IN systemname)

which clearly want to define the cGH pointer as

	cGH const *

There is no real problem in C, because casting in and out of const is 
merely worth a warning, which most people will ignore.  The problem is 
in C++, where the const has to be explicitly put in and taken out 
again.  (My case was an aliased function which calls another function 
that takes CCTK_ARGUMENTS.)



We should decide: Either the cGH structure should be const qualified in 
thorns, or it should not be.  If it is const, then the few thorns that 
need to modify the cGH structure (Time, CartGrid3D, drivers) can easily 
cast the const away in the few places where they need to modify things.

-erik

-- 
Erik Schnetter <schnetter at aei.mpg.de>   http://www.aei.mpg.de/~eschnett/

My email is as private as my paper mail.  I therefore support encrypting
and signing email messages.  Get my PGP key from www.keyserver.net.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.cactuscode.org/pipermail/developers/attachments/20050605/35c4f440/attachment-0002.bin 


More information about the Developers mailing list