# Coding for the differences in 5.3 and 5.4 _zend_class_entry structure.

- Thread: https://externals.io/message/54109
- Original archive: https://news-web.php.net/php.internals/54109
- Started by Richard Quadling on 2011-07-20T11:25:07+00:00
- Messages: 2
- 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

---

## #54109 — Richard Quadling — 2011-07-20T11:25:07+00:00

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

Hi.

Just seeing if I can get a small extension upgraded from 5.3 to 5.4
(the pecl/inclued extension). This is my attempt to learn more about
internals and hopefully increase my contribution to the project.

Prior to doing any work, I'm getting these errors ...

..\pecl\inclued\inclued.c(116) : error C2039: 'filename' : is not a
member of '_zend_class_entry'
        D:\BuildPHP\PHP_5_4\PHP_5_4\Zend\zend.h(462) : see declaration
of '_zend_class_entry'

..\pecl\inclued\inclued.c(116) : error C2198: 'add_assoc_string_ex' :
too few arguments for call

..\pecl\inclued\inclued.c(117) : error C2039: 'line_start' : is not a
member of '_zend_class_entry'
        D:\BuildPHP\PHP_5_4\PHP_5_4\Zend\zend.h(462) : see declaration
of '_zend_class_entry'

..\pecl\inclued\inclued.c(117) : error C2198: 'add_assoc_long_ex' :
too few arguments for call

..\pecl\inclued\inclued.c(130) : error C2039: 'filename' : is not a
member of '_zend_class_entry'
        D:\BuildPHP\PHP_5_4\PHP_5_4\Zend\zend.h(462) : see declaration
of '_zend_class_entry'

..\pecl\inclued\inclued.c(130) : error C2198: 'add_assoc_string_ex' :
too few arguments for call

..\pecl\inclued\inclued.c(131) : error C2039: 'line_start' : is not a
member of '_zend_class_entry'
        D:\BuildPHP\PHP_5_4\PHP_5_4\Zend\zend.h(462) : see declaration
of '_zend_class_entry'

..\pecl\inclued\inclued.c(131) : error C2198: 'add_assoc_long_ex' :
too few arguments for call

So, filename and line_start are missing and should be
user.info.filename and info.user.line_start.

At this stage, I'm guessing that the add_assoc_string_ex errors are a
knock-on effect as I can't see any difference in the macro
definitions.


So, I assume there has to be a #define to separate ...

		add_assoc_string_ex(class_entry, "filename", sizeof("filename"),
ce->filename, 1);
and
		add_assoc_string_ex(class_entry, "filename", sizeof("filename"),
ce->info.user.filename, 1);

http://svn.php.net/viewvc/pecl/apc/trunk/apc_zend.h?r1=303382&r2=303383&
introduced a set of macros to cover some of the elements of
zend_class_entry, but not for all of the elements of info.user, but
contains an adequate pattern to implement the rest of the elements.

Adding ...

#if ZEND_MODULE_API_NO >= 20100409
#define ZEND_ENGINE_2_4
#endif
...
#if defined(ZEND_ENGINE_2_4)
#define ZEND_CE_FILENAME(ce)  (ce)->info.user.filename
#define ZEND_CE_LINESTART(ce) (ce)->info.user.line_start
#else
#define ZEND_CE_FILENAME(ce)  (ce)->filename
#define ZEND_CE_LINESTART(ce) (ce)->line_start
#endif

to inclued_zend.h (I don't know if I should put these in
inclued_zend.h or php_include.h) and using these macros in inclued.c
would be a start, but there are 2 ways I've found of determining the
ZEND_ENGINE value.

http://lxr.php.net/opengrok/xref/PECL/bcompiler/php_bcompiler.h#54,
http://lxr.php.net/opengrok/xref/PECL/apc/apc_php.h#51 (others
extensions also use #if ZEND_MODULE_API_NO >= 20100409 ...).


As several extensions have had to implement these #defines to
distinguish between the different zend engine versions, should these
"level playing field" macros be moved (and completed) form the
extension to core?

OOI. Applying those changes allows inclued.c to compile, but now
leaves me with errors in inclued_zend.c. These seem to be similar in
issue but relate to the znode structures.



-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

---

## #54115 — Stas Malyshev — 2011-07-21T01:27:20+00:00

URL: https://externals.io/message/54109#54115 · In reply to: #54109

Hi!


> As several extensions have had to implement these #defines to
> distinguish between the different zend engine versions, should these
> "level playing field" macros be moved (and completed) form the
> extension to core?

If you're talking about ZEND_CE_FILENAME and similar ones, we could add 
it into 5.4, but we couldn't retroactively add it to existing PHP 
sources, so you'd have to ifdef in your extension anyway. At which point 
adding it into 5.4 becomes kind of useless.
So if you have any idea of how that would be useful please explain.

If you're talking about ZEND_ENGINE_2_4 macro, we could have it, though 
ZEND_MODULE_API_NO is more precise and safe to use. The problem is now 
that many modules have added it, adding it in core would actually make 
those modules issue warnings, so I'm not sure we actually should do it :)
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
