Re: [AD] constness in ugetx() |
[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]
Having trawled through the comp.lang.c FAQ, I found: http://www.eskimo.com/~scs/C-faq/q11.10.html Why can't I pass a char ** to a function which expects a const char **? ---------------------------------------------------------------------- You can use a pointer-to-T (for any type T) where a pointer-to-const-T is expected. However, the rule (an explicit exception) which permits slight mismatches in qualified pointer types is not applied recursively, but only at the top level. You must use explicit casts (e.g. (const char **) in this case) when assigning (or passing) pointers which have qualifier mismatches at other than the first level of indirection. Hrm... great. So it seems that there are only two `good' solutions to this problem: - remove `const'-correctness from Allegro, which would break all programs using `const'-correctness. - provide two versions of the function (problem in C; not in C++). Logically, `ugetx' would take `char**' (since it was like this before `const'-correctness came along), and `ugetx_const' would take `const char**'. 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/ |