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
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
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
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:
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
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
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:
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