# New Ticket Created by  Klaas-Jan Stol 
# Please include the string:  [perl #41637]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=41637 >


hi,

SMOP_class.pmc and smop_attribute.pmc won't compile on microsoft visual 
studio, because some declarations are not at the top of the block (which 
is demanded by MSVC, not by gcc).

this patch fixes that. (although I'm still having problems making:

"Compiling with:"
xx.c
cl -I.\include -nologo -GF -W3 -MD -Zi -DNDEBUG -DWIN32 -D_CONSOLE 
-DNO_STRICT -DNO_HASH_SEED -DUSE_SITECUSTOMIZE -D_CRT
_SECURE_NO_DEPRECATE -Zi -DHAS_JIT -DI386 -I. -Fo xx.obj -c xx.c
        C:\Perl\bin\perl.exe tools\build\pmc2c.pl --dump 
src\pmc\smop_class.pmc
        C:\Perl\bin\perl.exe tools\build\pmc2c.pl --c src\pmc\smop_class.pmc
        C:\Perl\bin\perl.exe tools\build\c2str.pl src\pmc\smop_class.c > 
src\pmc\smop_class.str
        C:\Perl\bin\perl.exe tools\build\c2str.pl --all
src\string.c
src\pmc\smop_class.c
C:/parrot4/tools/build/../../lib/Parrot/Pmc2c/PMETHODs.pm(433) : warning 
C4102: 'name_returns' : unreferenced label
C:/parrot4/tools/build/../../lib/Parrot/Pmc2c/PMETHODs.pm(525) : error 
C2275: 'STRING' : illegal use of this type as an
expression
        C:\parrot4\include\parrot/string.h(55) : see declaration of 'STRING'
C:/parrot4/tools/build/../../lib/Parrot/Pmc2c/PMETHODs.pm(510) : error 
C2059: syntax error : '}'
NMAKE : fatal error U1077: 'C:\Perl\bin\perl.exe' : return code '0x2'

Stop.

==========

So there seems to be something wrong in the PMETHODs.pm file...

regards,
kjs
Index: src/pmc/smop_attribute.pmc
===================================================================
--- src/pmc/smop_attribute.pmc	(revision 17213)
+++ src/pmc/smop_attribute.pmc	(working copy)
@@ -20,22 +20,26 @@
 */
 
 #include "parrot/parrot.h"
-#define SMOP_attr(o) ((SMOP_Attribute *) PMC_data(o))
 
+
 typedef struct SMOP_Attribute {
     STRING *name;
     STRING *type_;
     PMC *class_;
 } SMOP_Attribute;
 
+#define SMOP_attr(o) ((SMOP_Attribute *) PMC_data(o))
+
 static void smop_init(Interp *interp, PMC *self) {
+    SMOP_Attribute *smop = NULL;
+
     /* turn on marking of the class_data array */
     PObj_data_is_PMC_array_SET(self);
     /* turn on custom destruction since our PMC* array is dynamically allocated */
     PObj_active_destroy_SET(self);
 
     PMC_data(self) = mem_sys_allocate_zeroed(sizeof(SMOP_Attribute));
-    SMOP_Attribute *smop = SMOP_attr(self);
+    smop = SMOP_attr(self);
 }
 
 
@@ -88,10 +92,11 @@
 
 */
     PMETHOD void name(PMC *name :optional, int got_name :opt_flag) {
+        STRING *name_attr = NULL;
         if ( got_name ) {
             SMOP_attr(SELF)->name = VTABLE_get_string(interp, name);
         }
-        STRING* name_attr = SMOP_attr(SELF)->name;
+        name_attr = SMOP_attr(SELF)->name;
         preturn( STRING *name_attr );
     }
 /*
@@ -104,10 +109,11 @@
 
 */
     PMETHOD void class(PMC *class :optional, int got_class :opt_flag) {
+        PMC* class_attr = NULL;
         if ( got_class ) {
             SMOP_attr(SELF)->class_ = class;
         }
-        PMC* class_attr = SMOP_attr(SELF)->class_;
+        class_attr = SMOP_attr(SELF)->class_;
         preturn( PMC *class_attr );
     }
 /*
@@ -120,10 +126,11 @@
 
 */
     PMETHOD void type(PMC *type :optional, int got_type :opt_flag) {
+        STRING* type_string = NULL;
         if ( got_type ) {
             SMOP_attr(SELF)->type_ = VTABLE_get_string(interp, type);
         }
-        STRING* type_string = SMOP_attr(SELF)->type_;
+        type_string = SMOP_attr(SELF)->type_;
         preturn( STRING *type_string );
     }
 }
Index: src/pmc/smop_class.pmc
===================================================================
--- src/pmc/smop_class.pmc	(revision 17213)
+++ src/pmc/smop_class.pmc	(working copy)
@@ -32,6 +32,7 @@
 } SMOP_Class;
 
 static void smop_init(Interp *interp, PMC *self) {
+    SMOP_Class *smop = NULL;
     /* But we are a class, really */
     PObj_is_class_SET(self);
     /* turn on marking of the class_data array */
@@ -40,7 +41,7 @@
     PObj_active_destroy_SET(self);
 
     PMC_data(self) = mem_sys_allocate_zeroed(sizeof(SMOP_Class));
-    SMOP_Class *smop = SMOP(self);
+    smop = SMOP(self);
     smop->attributes    = pmc_new(interp, enum_class_Hash);
     smop->methods       = pmc_new(interp, enum_class_Hash);
     smop->superclasses  = pmc_new(interp, enum_class_Hash);

Reply via email to