# ZSTR and NULL problems again

- Thread: https://externals.io/message/22936
- Original archive: https://news-web.php.net/php.internals/22936
- Started by Andrei Zmievski on 2006-04-24T21:34:44+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #22936 — Andrei Zmievski — 2006-04-24T21:34:44+00:00

URL: https://externals.io/message/22936#22936

After Frank's latest changes, HEAD doesn't compile under gcc 2.95 
anymore:

/homes/andrei/dev/php-src/ext/spl/spl_directory.c:1359: cast to union 
type from type not present in union

That line is:

         buf = php_stream_get_line(intern->u.file.stream, NULL, 0, 
&line_len);

Definition of php_stream_get_line():

	#define php_stream_get_line(stream, buf, maxlen, retlen)    
_php_stream_get_line((stream), IS_STRING, ZSTR(buf), (maxlen), 0, 
(retlen) TSRMLS_CC)

And under GCC ZSTR is defined as:

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")

So, do we have to pass (void*)NULL everywhere now? Or can we do this in 
a cross-platform way somehow?

-Andrei

---

## #22942 — Dmitry Stogov — 2006-04-25T05:37:02+00:00

URL: https://externals.io/message/22936#22942 · In reply to: #22936

What was the problem with NULL_ZSTR?

Dmitry.

> -----Original Message-----
> From: Andrei Zmievski [mailto:andrei@gravitonic.com] 
> Sent: Tuesday, April 25, 2006 1:35 AM
> To: PHP Internals
> Cc: Dmitry Stogov; Frank M. Kromann
> Subject: ZSTR and `NULL` problems again
> 
> 
> After Frank's latest changes, HEAD doesn't compile under gcc 2.95 
> anymore:
> 
> /homes/andrei/dev/php-src/ext/spl/spl_directory.c:1359: cast to union 
> type from type not present in union
> 
> That line is:
> 
>          buf = php_stream_get_line(intern->u.file.stream, NULL, 0, 
> &line_len);
> 
> Definition of php_stream_get_line():
> 
> 	#define php_stream_get_line(stream, buf, maxlen, retlen)    
> _php_stream_get_line((stream), IS_STRING, ZSTR(buf), (maxlen), 0, 
> (retlen) TSRMLS_CC)
> 
> And under GCC ZSTR is defined as:
> 
> 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")
> 
> So, do we have to pass (void*)NULL everywhere now? Or can we 
> do this in 
> a cross-platform way somehow?
> 
> -Andrei

---

## #22944 — Wez Furlong — 2006-04-25T05:46:33+00:00

URL: https://externals.io/message/22936#22944 · In reply to: #22936

I think ZSTR(buf) should not be present in the macro:

#define php_stream_get_line(stream, buf, maxlen, retlen)
   _php_stream_get_line((stream), IS_STRING, (buf), (maxlen), 0,
   (retlen) TSRMLS_CC)

Let the caller apply ZSTR() to the argument manually, if that is required.

--Wez.


>         #define php_stream_get_line(stream, buf, maxlen, retlen)
> _php_stream_get_line((stream), IS_STRING, ZSTR(buf), (maxlen), 0,
> (retlen) TSRMLS_CC)

---

## #22964 — Sara Golemon — 2006-04-25T19:29:21+00:00

URL: https://externals.io/message/22936#22964 · In reply to: #22944

Agreed.... Unless someone goes ahead and changes the get_line macro and 
places that call it, I'll do so when I get to the end of my second leg...

-Sara
----- Original Message ----- 
From: ""Wez Furlong"" <kingwez@gmail.com>
Newsgroups: php.internals
To: "Andrei Zmievski" <andrei@gravitonic.com>
Cc: "PHP Internals" <internals@lists.php.net>; "Dmitry Stogov" 
<dmitry@zend.com>; "Frank M. Kromann" <frank@kromann.info>
Sent: Monday, April 24, 2006 10:46 PM
Subject: Re: [PHP-DEV] ZSTR and `NULL` problems again


I think ZSTR(buf) should not be present in the macro:

#define php_stream_get_line(stream, buf, maxlen, retlen)
   _php_stream_get_line((stream), IS_STRING, (buf), (maxlen), 0,
   (retlen) TSRMLS_CC)

Let the caller apply ZSTR() to the argument manually, if that is required.

--Wez.


>         #define php_stream_get_line(stream, buf, maxlen, retlen)
> _php_stream_get_line((stream), IS_STRING, ZSTR(buf), (maxlen), 0,
> (retlen) TSRMLS_CC)
