FAQ
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

Search Discussions

  • Dmitry Stogov at Apr 25, 2006 at 5:37 am
    What was the problem with NULL_ZSTR?

    Dmitry.
    -----Original Message-----
    From: Andrei Zmievski
    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

  • Nuno Lopes at Apr 25, 2006 at 10:54 am
    The problem was the macro expansion (problematic on non-gcc builds):
    ZSTR(NULL_ZSTR) --> ZSTR(ZSTR((void*)NULL))

    But I agree with Wez and I thing that the ZSTR() should be removed from the
    php_stream_get_line() macro.

    BTW, I though it wasn't possible to build PHP with gcc 2.95 anymore. At
    least on Solaris I can't build PHP with gcc 2.95 for a long time ago.

    Nuno
    ----- Original Message -----
    What was the problem with NULL_ZSTR?

    Dmitry.
    -----Original Message-----
    From: Andrei Zmievski
    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
  • Wez Furlong at Apr 25, 2006 at 5:46 am
    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.
    On 4/24/06, Andrei Zmievski wrote:
    #define php_stream_get_line(stream, buf, maxlen, retlen)
    _php_stream_get_line((stream), IS_STRING, ZSTR(buf), (maxlen), 0,
    (retlen) TSRMLS_CC)
  • Sara Golemon at Apr 25, 2006 at 7:29 pm
    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.
    On 4/24/06, Andrei Zmievski wrote:
    #define php_stream_get_line(stream, buf, maxlen, retlen)
    _php_stream_get_line((stream), IS_STRING, ZSTR(buf), (maxlen), 0,
    (retlen) TSRMLS_CC)
  • Frank M. Kromann at Apr 25, 2006 at 3:45 pm
    NULL_ZSTR is not a problem, but when a macro defines ZSTR(buf) and buf is
    NULL_ZSTR you get ZSTR(NULL_ZSTR) which is invalid.

    - Frank
    What was the problem with NULL_ZSTR?

    Dmitry.
    -----Original Message-----
    From: Andrei Zmievski
    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

  • Frank M. Kromann at Apr 25, 2006 at 3:51 pm
    I Like that idea.

    - Frank
    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.
    On 4/24/06, Andrei Zmievski wrote:
    #define php_stream_get_line(stream, buf, maxlen, retlen)
    _php_stream_get_line((stream), IS_STRING, ZSTR(buf), (maxlen), 0,
    (retlen) TSRMLS_CC)
  • Frank M. Kromann at Apr 28, 2006 at 7:05 pm
    Hello Everyne,

    I have now removed the ZSTR() macros from the stream macros.

    Andrei will you please test that it compiles now?

    - Frank
    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.
    On 4/24/06, Andrei Zmievski wrote:
    #define php_stream_get_line(stream, buf, maxlen, retlen)
    _php_stream_get_line((stream), IS_STRING, ZSTR(buf), (maxlen), 0,
    (retlen) TSRMLS_CC)

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
  • Hannes Magnusson at Apr 29, 2006 at 11:17 am
    Hi Frank
    I have now removed the ZSTR() macros from the stream macros.

    Andrei will you please test that it compiles now?
    http://bugs.php.net/bug.php?id=37241
  • Nuno Lopes at Apr 29, 2006 at 11:36 am
    Here is a diff to fix a couple of missing ZSTR macros.


    ----- Original Message -----
    From: "Hannes Magnusson" <hannes.magnusson@gmail.com>
    To: "Frank M. Kromann" <frank@kromann.info>
    Cc: "Sara Golemon" <pollita@php.net>; "Wez Furlong" <kingwez@gmail.com>;
    "Andrei Zmievski" <andrei@gravitonic.com>; <internals@lists.php.net>
    Sent: Saturday, April 29, 2006 12:17 PM
    Subject: Re: [PHP-DEV] ZSTR and NULL problems again


    Hi Frank
    I have now removed the ZSTR() macros from the stream macros.

    Andrei will you please test that it compiles now?
    http://bugs.php.net/bug.php?id=37241
  • Frank M. Kromann at Apr 29, 2006 at 2:54 pm
    Thanks Nuno,

    Patch has been applied to CVS.

    There is still a couple of extensions that need same treatment. I'm going
    to look through the code and find these.

    - Frank
    Here is a diff to fix a couple of missing ZSTR macros.


    ----- Original Message -----
    From: "Hannes Magnusson" <hannes.magnusson@gmail.com>
    To: "Frank M. Kromann" <frank@kromann.info>
    Cc: "Sara Golemon" <pollita@php.net>; "Wez Furlong" <kingwez@gmail.com>;
    "Andrei Zmievski" <andrei@gravitonic.com>; <internals@lists.php.net>
    Sent: Saturday, April 29, 2006 12:17 PM
    Subject: Re: [PHP-DEV] ZSTR and NULL problems again


    Hi Frank
    I have now removed the ZSTR() macros from the stream macros.

    Andrei will you please test that it compiles now?
    http://bugs.php.net/bug.php?id=37241
  • Related Discussions

    Discussion Navigation
    viewthread | post
    Discussion Overview
    groupphp-internals @
    categoriesphp
    postedApr 24, '06 at 9:35p
    activeApr 29, '06 at 2:54p
    posts11
    users7
    websitephp.net

    People

    Translate

    site design / logo © 2022 Grokbase