FAQ
I have written an extension. Unfortunatelly I had to use some C++.
After building I have some problems with 3 functions:
zval_add_ref, REGISTER_LONG_CONSTANT, php_error_docref.
If I include their body within my extension, it's Ok.
Otherwise I got memory fault under PHP 4.3.0 and
relocation error: /usr/lib/php/xerces.so: undefined symbol: _Z12zval_add_refPP12_zval_struct
under 4.3.1. It has been built by gcc 3.2.2.
Could anyone spend few minutes on it:
http://ggodlewski.host.sk/download/php-xerces/php-xerces-0.1.tar.gz
It requires xerces-c-2.2.0.
Problematic places are marked by MEM_FAULT_HACK macro.

Thanks,
Grzegorz Godlewski

Search Discussions

  • Jay Smith at Apr 14, 2003 at 2:23 pm
    There are a few header files that you have to include with extern "C" so
    their names get mangled properly into C++. Try wrapping php.h, php_ini.h
    and info.h in extern "C" and see how that goes.

    I wrote up a little article on this sort of thing, so if you're interested,
    check out http://www.tutorbuddy.com/software/phpcpp/phpcpp/.

    J


    Grzegorz Godlewski wrote:
    I have written an extension. Unfortunatelly I had to use some C++.
    After building I have some problems with 3 functions:
    zval_add_ref, REGISTER_LONG_CONSTANT, php_error_docref.
    If I include their body within my extension, it's Ok.
    Otherwise I got memory fault under PHP 4.3.0 and
    relocation error: /usr/lib/php/xerces.so: undefined symbol:
    _Z12zval_add_refPP12_zval_struct under 4.3.1. It has been built by gcc
    3.2.2. Could anyone spend few minutes on it:
    http://ggodlewski.host.sk/download/php-xerces/php-xerces-0.1.tar.gz
    It requires xerces-c-2.2.0.
    Problematic places are marked by MEM_FAULT_HACK macro.

    Thanks,
    Grzegorz Godlewski
  • Per Lundberg at Apr 14, 2003 at 4:10 pm

    On Mon, 2003-04-14 at 16:19, Jay Smith wrote:
    There are a few header files that you have to include with extern "C" so
    their names get mangled properly into C++. Try wrapping php.h, php_ini.h
    and info.h in extern "C" and see how that goes.
    How come we don't have extern C wrapped in #ifdef __cplusplus in these
    files already, so they can just be included straight away? Like this:

    #ifdef __cplusplus
    extern "C" {
    #endif

    // yadda yadda

    #ifdef __cplusplus
    };
    #endif

    --
    Best regards,

    Per Lundberg / Capio ApS
    Phone: +46-18-4186040
    Fax: +46-18-4186049
    Web: http://www.nobolt.com
  • Jay Smith at Apr 14, 2003 at 4:26 pm
    It kind of seems messy to wrap everything in extern "C". It would probably
    be better to weed out the individual API functions that need to be extern
    C'd. I'll try and seek out the offending functions. There aren't too many
    of them AFAIK...

    J


    Per Lundberg wrote:
    On Mon, 2003-04-14 at 16:19, Jay Smith wrote:
    There are a few header files that you have to include with extern "C" so
    their names get mangled properly into C++. Try wrapping php.h, php_ini.h
    and info.h in extern "C" and see how that goes.
    How come we don't have extern C wrapped in #ifdef __cplusplus in these
    files already, so they can just be included straight away? Like this:

    #ifdef __cplusplus
    extern "C" {
    #endif

    // yadda yadda

    #ifdef __cplusplus
    };
    #endif

    --
    Best regards,

    Per Lundberg / Capio ApS
    Phone: +46-18-4186040
    Fax: +46-18-4186049
    Web: http://www.nobolt.com
  • Per Lundberg at Apr 14, 2003 at 4:32 pm

    On Mon, 2003-04-14 at 18:26, Jay Smith wrote:
    It kind of seems messy to wrap everything in extern "C".
    Well, I think it's kind of standard procedure when writing C APIs. Do a
    grep on __cplusplus in your /usr/include for example. But do it any way
    you like, as long as it works...
    --
    Best regards,

    Per Lundberg / Capio ApS
    Phone: +46-18-4186040
    Fax: +46-18-4186049
    Web: http://www.nobolt.com
  • Jay Smith at Apr 14, 2003 at 4:54 pm
    I believe Zeev suggested doing it on a per API function basis. Should be in
    the archives some place, so I can't take credit for the suggestion. I don't
    really care how it's done either, so long as it works. Looking over the
    Zend code, it seems that most of the ZEND_API are wrapped in
    BEGIN/END_EXTERN_C(), so for the sake of consistency that's probably the
    way to go.

    J


    Per Lundberg wrote:
    On Mon, 2003-04-14 at 18:26, Jay Smith wrote:
    It kind of seems messy to wrap everything in extern "C".
    Well, I think it's kind of standard procedure when writing C APIs. Do a
    grep on __cplusplus in your /usr/include for example. But do it any way
    you like, as long as it works...
    --
    Best regards,

    Per Lundberg / Capio ApS
    Phone: +46-18-4186040
    Fax: +46-18-4186049
    Web: http://www.nobolt.com

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedApr 12, '03 at 12:58p
activeApr 14, '03 at 4:54p
posts6
users3
websitephp.net

People

Translate

site design / logo © 2022 Grokbase