Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37259 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84496 invoked from network); 27 Apr 2008 04:46:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Apr 2008 04:46:57 -0000 X-Host-Fingerprint: 24.228.80.153 ool-18e45099.dyn.optonline.net Received: from [24.228.80.153] ([24.228.80.153:11880] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 70/D0-10241-04504184 for ; Sun, 27 Apr 2008 00:46:57 -0400 Message-ID: <70.D0.10241.04504184@pb1.pair.com> To: internals@lists.php.net Date: Sun, 27 Apr 2008 00:46:59 -0400 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041206 Thunderbird/1.0 Mnenhy/0.6.0.104 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Posted-By: 24.228.80.153 Subject: Const-correctness with Zend From: edwardzyang@thewritingpot.com ("Edward Z. Yang") I'm getting persistent const qualifier warnings with MSVC 2005 Express, along these lines: ..\extra\uriparser\uriparser.c(227) : warning C4090: 'function' : different 'const' qualifiers where line 227 looks like add_next_index_stringl(path_array, walker->text.first, walker->text.afterLast - walker->text.first, 1); ...where walker->text.first is a const char*. Now, because Zend is duplicating the value, it should be possible for this pointer to be const without causing warnings. (The alternative to estrndup it myself and not use duplicate, but that kind of defeats the purpose of duplicate, doesn't it?). As it turns out, it appears this message appears elsewhere in extensions too (just grep the Windows snapshot logs for C4090: 'function'). Since C doesn't support function overloading, this would probably mean macro-fying the relevant functions in the core to call separate duplicate and non-duplicate functions. In addition, the ZVAL_ macros would need to somehow add a const qualifier to the temporary string pointer if duplicate is true (I don't know if that's possible or not). I can produce a patch, although monkeying around in Zend is something probably best left to the experts. Still, I'm wondering if this would be a good idea or not. Code-wise, it should be fully backwards and forwards compatible (warnings simply disappear in newer versions), although it wouldn't be binary compatible. Or you could just tell me to estrndup. Thanks! -- Edward Z. Yang GnuPG: 0x869C48DA HTML Purifier Anti-XSS Filter [[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]