I'm doing some kind of research related to mod_perl-Apache-Perl compatibility. Recently I tried to build mod_perl 2.0.4 using Perl 5.14.2. The compilation phase was terminated prematurely with an error:
modperl_perl.c: In function ‘modperl_perl_core_global_init’:
modperl_perl.c:58:9: error: lvalue required as left operand of assignment
In this place the following code is written:
GvCV(gv) = get_cv(cglobals->sub_name, TRUE);
Searching for what could generate this error, I have found a difference between previous versions of Perl and Perl 5.14 (CORE/gv.h):
#define GvCV(gv) (GvGP(gv)->gp_cv) /* previous versions */
vs
#define GvCV(gv) (0+GvGP(gv)->gp_cv) /* in Perl 5.14 */
Removing this 0+
from the definition allows mod_perl 2.0.4 to be compiled successfully, and this is fine because 0+...
is not recognized as an lvalue compared to previous versions.
Why is 0+
used in the definition of GvCV and is it necessary? or is it safe to remove it and have the definition of GvCV(gv)
like in previous versions of Perl?
0+
prefix is added in order to eliminate any usage of CVs as lvalues and make developers useGvCV_set()
instead. And it's not safe to remove this0+
prefix. Did I correctly understand? about mod_perl: it has newer versions compiling successfully with Perl 5.14 (just looked,GvCV_set()
is used there); 2.0.4 is an old one. I think your answer is close enough to what I expected. Thanks. – Sesquicentennial