On Tue, Oct 20, 2009 at 4:03 PM, Barry Scott <ba...@barrys-emacs.org> wrote:
> Checking my patch I have two functions that need to > have output params changed to const to avoid casting. > > PyOS_strtoul - ptr > PyLong_FromString - pend > This is a no-win situation. If the string is const in the caller, they currently need to cast it. If you make the change, then if string is not const in the caller then they will need to cast it. I've provided a short example below and marked the lines that generate "an incompatible pointer type" warning with gcc. I suggest following POSIX's lead and omitted the const in these cases. void test_const(const char **foo); void test_noconst(char **foo); int main(void) { char *noconst_var; const char *const_var; test_const(&noconst_var); // generates a warning test_const(&const_var); test_noconst(&noconst_var); test_noconst(&const_var); // generates a warning return 0; } -- Daniel Stutzbach, Ph.D. President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com