[Pyrex] Support for qualifiers

Andreas Kostyrka andreas at kostyrka.org
Fri Mar 28 09:54:21 CET 2008


Actually, one thing that might be non trivial is the fact that you can
have a non-const pointer to something const, you can have a const
pointer to something non-const, and naturally, a const pointer to
something const.

To solve the problem generically, you have 2**(n+1) different kinds of
const-ness possible a n-types pointer.

main() {
    const int a=10;
    int b=11;
    const int *p = &a;
    int * const o = &b;
    const int * const q = &a;
}

Andreas

Am Mittwoch, den 26.03.2008, 12:25 +1200 schrieb Greg Ewing:
> Jelmer Vernooij wrote:
> > I figured it would simply be a matter of tracking whether
> > something is const. Would there be more required than that?
> 
> The type compatibility rules all become more complicated.
> For instance, you can assign a char * to a const char *,
> but not the other way around.
> 
> The parsing gets more complicated as well. I'm not even
> confident I know all the places you're allowed to insert
> a 'const' into a C declaration, and what they all mean.
> 
> It's all doable, but it will require some careful thought.
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://lists.copyleft.no/pipermail/pyrex/attachments/20080328/d61daae5/attachment.bin 


More information about the Pyrex mailing list