[Developers] Const correctness for cGH *

Gabrielle Allen gallen at cct.lsu.edu
Sun Jun 5 13:44:08 CDT 2005


Should/could the thorns request a modifiable cGH in the interface.ccl  
so could also track which of them are playing around with it?

On Jun 5, 2005, at 1:35 PM, Erik Schnetter wrote:

> 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.
> _______________________________________________
> Developers mailing list
> Developers at cactuscode.org
> http://www.cactuscode.org/mailman/listinfo/developers
>




More information about the Developers mailing list