Re: [AD] The details of 'const' |
[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]
In reply to Ben Davis <ben@xxxxxxxxxx>: >Hence, at least in DJGPP, it *is* possible to tell the compiler exactly >what we mean. In this case, we want a pointer to a variable pointer to a >constant string, so "const char **" is fine for ugetx(). It just means >that the string is constant; not the pointer. This isn't the same; that was why I introduced ugetxc() in the first place. Don't you get a warning/error when you try to compile the following code? int test(const char* p) { return ugetx(&p); } The *reason* is this: if you pass a ptr-to-ptr-to-char to a function expecting a ptr-to-ptr-to-const-char, then that function *might* set the ptr-to-ptr to point at some const char data. Then, when the function returns, the code executed after the function doesn't see that char data as const-qualified. Hence the error. Also, you can look in the C FAQ-list, which tells you that the process by which non-const data can be passed to a const-function only goes down one level, although it doesn't explain why. Bye for now, -- Laurence Withers, lwithers@xxxxxxxxxx http://www.lwithers.demon.co.uk/
Attachment:
signature.asc
Description: PGP signature
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |