Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>After posting I came across <a href="http://php-baustelle.de/CodeGen_PECL/manual.html" rel="noreferrer">CodeGen_PECL</a> which creates a skeleton extension from an XML based description of the extension. This includes a tag make it output C++</p> <p>As well as making sure the header file used extern "C", the generated cpp file also ensured the ZEND_GET_MODULE(hello) was inside an extern "C" block also.</p> <p>As expected, the biggest difference was in the m4 file, which looked like this:</p> <pre><code>dnl dnl $ Id: $ dnl PHP_ARG_ENABLE(hello, whether to enable hello functions, [ --enable-hello Enable hello support]) if test "$PHP_HELLO" != "no"; then PHP_REQUIRE_CXX AC_LANG_CPLUSPLUS PHP_ADD_LIBRARY(stdc++,,HELLO_SHARED_LIBADD) export OLD_CPPFLAGS="$CPPFLAGS" export CPPFLAGS="$CPPFLAGS $INCLUDES -DHAVE_HELLO" AC_MSG_CHECKING(PHP version) AC_TRY_COMPILE([#include &lt;php_version.h&gt;], [ #if PHP_VERSION_ID &lt; 40000 #error this extension requires at least PHP version 4.0.0 #endif ], [AC_MSG_RESULT(ok)], [AC_MSG_ERROR([need at least PHP 4.0.0])]) export CPPFLAGS="$OLD_CPPFLAGS" PHP_SUBST(HELLO_SHARED_LIBADD) AC_DEFINE(HAVE_HELLO, 1, [ ]) PHP_NEW_EXTENSION(hello, hello.cpp , $ext_shared) fi </code></pre> <p>So, if you're struggling with the same problem, use <a href="http://php-baustelle.de/CodeGen_PECL/manual.html" rel="noreferrer">CodeGen_PECL</a>, or adapt the m4 sample above (as well as making sure you've used extern "C" in your header and around the ZEND_GET_MODULE macro)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload