# New Ticket Created by Ron Blaschke
# Please include the string: [perl #39849]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=39849 >
Problem: languages/lua doesn't compile on Win32, with the following
error message.
luanumber.c
luanumber.c(1152) : error C2143: syntax error : missing ';' before
'type'
luanumber.c(1154) : error C2065: 'my_enum_class_LuaString' :
undeclared identifier
luanumber.c(1195) : error C2143: syntax error : missing '{' before
'*'
luanumber.c(1197) : error C2371: 'Parrot_lib_luanumber_load' :
redefinition; different basic types
luanumber.c(1195) : see declaration of
'Parrot_lib_luanumber_load'
compile luanumber.c failed (512)
The reason for this is the following initialization, in the middle of
function Parrot_LuaNumber_class_init.
int my_enum_class_LuaString = pmc_type(interp,
string_from_const_cstring(interp, "LuaString", 0));
Possible Solution: Attached patch adds a block around the MMD
initializer code, which should bring the generated code back to valid C.
Changed Files: lib/Parrot/Pmc2c.pm
Index: lib/Parrot/Pmc2c.pm
===================================================================
--- lib/Parrot/Pmc2c.pm (revision 13316)
+++ lib/Parrot/Pmc2c.pm (working copy)
@@ -951,23 +951,27 @@
$class_init_code
EOC
+ $cout .= <<"EOC";
+ {
+EOC
+
# declare auxiliary variables for dyncpmc IDs
foreach my $dynpmc (keys %init_mmds) {
next if $dynpmc eq $classname;
$cout .= <<"EOC";
- int my_enum_class_$dynpmc = pmc_type(interp,
string_from_const_cstring(interp, "$dynpmc", 0));
+ int my_enum_class_$dynpmc = pmc_type(interp,
string_from_const_cstring(interp, "$dynpmc", 0));
EOC
}
# init MMD "right" slots with the dynpmc types
foreach my $entry (@init_mmds) {
if ($entry->[1] eq $classname) {
$cout .= <<"EOC";
- _temp_mmd_init[$entry->[0]].right = entry;
+ _temp_mmd_init[$entry->[0]].right = entry;
EOC
}
else {
$cout .= <<"EOC";
- _temp_mmd_init[$entry->[0]].right = my_enum_class_$entry->[1];
+ _temp_mmd_init[$entry->[0]].right = my_enum_class_$entry->[1];
EOC
}
}
@@ -975,18 +979,19 @@
foreach my $dynpmc (keys %init_mmds) {
next if $dynpmc eq $classname;
$cout .= <<"EOC";
- assert(my_enum_class_$dynpmc != enum_class_default);
+ assert(my_enum_class_$dynpmc != enum_class_default);
EOC
}
if (scalar @mmds) {
$cout .= <<"EOC";
#define N_MMD_INIT (sizeof(_temp_mmd_init)/sizeof(_temp_mmd_init[0]))
- Parrot_mmd_register_table(interp, entry,
- _temp_mmd_init, N_MMD_INIT);
+ Parrot_mmd_register_table(interp, entry,
+ _temp_mmd_init, N_MMD_INIT);
EOC
}
$cout .= <<"EOC";
+ }
} /* pass */
} /* Parrot_${classname}_class_init */
EOC