Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:22387 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14941 invoked by uid 1010); 13 Mar 2006 23:35:44 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 14925 invoked from network); 13 Mar 2006 23:35:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Mar 2006 23:35:44 -0000 X-Host-Fingerprint: 200.196.123.37 unknown Received: from ([200.196.123.37:13634] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id DB/BF-55982-FC106144 for ; Mon, 13 Mar 2006 18:35:43 -0500 Message-ID: To: internals@lists.php.net Date: Mon, 13 Mar 2006 20:34:51 -0300 Lines: 56 User-Agent: KNode/0.10.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Posted-By: 200.196.123.37 Subject: ZSTR cast to union not working on g++ From: cunha17@gmail.com (Cristiano Duarte) In zend.h, ZSTR is defined like this: typedef union _zstr { char *s; UChar *u; void *v; } zstr; #ifdef __GNUC__ # define ZSTR(x) ((zstr)(x)) # define NULL_ZSTR ZSTR((void*)NULL) # define EMPTY_ZSTR ZSTR("\0\0") #else extern ZEND_API zstr null_zstr; extern ZEND_API zstr empty_zstr; static inline zstr _to_zstr(void *v) { zstr ret; ret.v = v; return ret; } # define ZSTR(x) _to_zstr(x) # define NULL_ZSTR null_zstr # define EMPTY_ZSTR empty_zstr #endif The problem is that g++ is also __GNUC__ and I just can't get g++ to compile a code like this: char *c="I am not working!"; zstr z = ZSTR(c); So I found at gcc.gnu.org that the "Cast to Union" GNU extension is just for C not C++, here is the patch to the current CVS: Index: Zend/zend.h =================================================================== RCS file: /repository/ZendEngine2/zend.h,v retrieving revision 1.316 diff -u -u -r1.316 zend.h --- Zend/zend.h 3 Mar 2006 09:56:47 -0000 1.316 +++ Zend/zend.h 13 Mar 2006 23:29:45 -0000 @@ -246,7 +246,7 @@ void *v; } zstr; -#ifdef __GNUC__ +#if defined(__GNUC__) && ! defined(__GNUG__) # define ZSTR(x) ((zstr)(x)) # define NULL_ZSTR ZSTR((void*)NULL) # define EMPTY_ZSTR ZSTR("\0\0") Regards, Cristiano Duarte