[Developers] Const correctness for cGH *
Erik Schnetter
schnetter at aei.mpg.de
Tue Jun 7 07:12:00 CDT 2005
On Tuesday 07 June 2005 14:05, Thomas Radke wrote:
> Jonathan Thornburg wrote:
> > On Sun, 5 Jun 2005, Erik Schnetter wrote:
> > [[...]]
> >
> >> 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.
> >
> > Yes, make it const!
>
> I'd be in favor of it too. But only if you can tell me how to do the
> type cast in C without having gcc generate a warning "cast discards
> qualifiers from pointer target type" for such cases.
You have to use an explicit case. In the example below,
void sub (const int * pci)
{
int * pi1 = pci;
int * pi2 = (int *) pci;
++ * pi1;
++ * pi2;
}
pi1 is set without an explicit cast and leads to the warning. pi2 gives
no warning (with both gcc and Intel).
-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/20050607/c9536a58/attachment-0002.bin
More information about the Developers
mailing list