--- Begin Message ---
As a follow-up to the earlier report, here is a patch that fixes the
warnings for perl at least.  I actually tried to send this one directly
to the upstream -dev list, but whoever their moderator du jour is, was
either blind to the tag [PATCH] in the subject, swamped by a ton of
spam and missed it, or has a very strange attitude to accepting
contributions, since it got manually bounced with no reason beyond:
"Non-members are not allowed to post messages to this list."

So I'll punt it through the BTS, and hope that either you have more
luck forwarding it, or it gets rejected for a slightly more sensible
reason next time ...

Cheers,
Ron



Hi,

I had to update to the svn source yesterday because I needed the fix
for template methods returning a smart pointer, so while I'm on the
pointy end, here's a patch that fixes some g++-4.1 compiler warnings
in the wrappers for perl which I was also seeing.  ;)

The fix for the unused variable should be self-evident, the fix for
casting away const uses a macro because I assume this also needs to
build with the C compiler.  I'm not sure if that is really the right
place to define the macro, or the right thing to call it, so you may
want to tweak that a bit further.

There are some similar warnings for python which I outlined (along
with details of the compiler flags I've been using) here:
http://bugs.debian.org/436711

but this patch only covers what I'm currently seeing with perl.
If I hit any more, I'll pass along fixes as I find them.

Aside from that, so far so good, Thanks!

 Ron


diff --git a/Lib/perl5/perlinit.swg b/Lib/perl5/perlinit.swg
index 68bf6d8..c70ff7b 100644
--- a/Lib/perl5/perlinit.swg
+++ b/Lib/perl5/perlinit.swg
@@ -29,29 +29,33 @@ XS(SWIG_init) {
     dXSARGS;
     int i;
 
+    (void)items;
+
     SWIG_InitializeModule(0);
 
     /* Install commands */
     for (i = 0; swig_commands[i].name; i++) {
-      newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, 
(char*)__FILE__);
+      newXS(CONST_CAST(char*,swig_commands[i].name), swig_commands[i].wrapper,
+            CONST_CAST(char*,__FILE__));
     }
 
     /* Install variables */
     for (i = 0; swig_variables[i].name; i++) {
       SV *sv;
-      sv = get_sv((char*) swig_variables[i].name, TRUE | 0x2);
+      sv = get_sv(CONST_CAST(char*,swig_variables[i].name), TRUE | 0x2);
       if (swig_variables[i].type) {
        SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0);
       } else {
        sv_setiv(sv,(IV) 0);
       }
-      swig_create_magic(sv, (char *) swig_variables[i].name, 
swig_variables[i].set, swig_variables[i].get); 
+      swig_create_magic(sv, CONST_CAST(char*,swig_variables[i].name),
+                        swig_variables[i].set, swig_variables[i].get);
     }
 
     /* Install constant */
     for (i = 0; swig_constants[i].type; i++) {
       SV *sv;
-      sv = get_sv((char*)swig_constants[i].name, TRUE | 0x2);
+      sv = get_sv(CONST_CAST(char*,swig_constants[i].name), TRUE | 0x2);
       switch(swig_constants[i].type) {
       case SWIG_INT:
        sv_setiv(sv, (IV) swig_constants[i].lvalue);

diff --git a/Lib/perl5/perlrun.swg b/Lib/perl5/perlrun.swg
index 1a4559d..3c651b2 100644
--- a/Lib/perl5/perlrun.swg
+++ b/Lib/perl5/perlrun.swg
@@ -69,7 +69,10 @@
 #define SWIG_POINTER_EXCEPTION  0
 
 #ifdef __cplusplus
+#define CONST_CAST(t,v) const_cast<t>(v)
 extern "C" {
+#else
+#define CONST_CAST(t,v) ((t)(v))
 #endif
 
 #define SWIG_OWNER   SWIG_POINTER_OWN
@@ -208,8 +211,10 @@ SWIG_Perl_TypeProxyName(const swig_type_info *type) {
 
 SWIGRUNTIME swig_cast_info *
 SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) {
-  SWIG_TypeCheck_Template(( (!iter->type->clientdata && 
(strcmp((char*)iter->type->name, c) == 0)) 
-                           || (iter->type->clientdata && 
(strcmp((char*)iter->type->clientdata, c) == 0))), ty);
+  SWIG_TypeCheck_Template(( (!iter->type->clientdata
+                             && (strcmp(CONST_CAST(char*,iter->type->name), c) 
== 0))
+                            || (iter->type->clientdata
+                                && (strcmp((char*)iter->type->clientdata, c) 
== 0))), ty);
 }
 
 
@@ -302,7 +307,7 @@ SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, 
swig_type_info *t, i
     SV *obj=newSV(0);
     HV *hash=newHV();
     HV *stash;
-    sv_setref_pv(obj, (char *) SWIG_Perl_TypeProxyName(t), ptr);
+    sv_setref_pv(obj, CONST_CAST(char*,SWIG_Perl_TypeProxyName(t)), ptr);
     stash=SvSTASH(SvRV(obj));
     if (flags & SWIG_POINTER_OWN) {
       HV *hv;
@@ -320,7 +325,7 @@ SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, 
swig_type_info *t, i
     sv_bless(sv, stash);
   }
   else {
-    sv_setref_pv(sv, (char *) SWIG_Perl_TypeProxyName(t), ptr);
+    sv_setref_pv(sv, CONST_CAST(char*,SWIG_Perl_TypeProxyName(t)), ptr);
   }
 }
 
-- 
1.5.2.4



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]


--- End Message ---

Reply via email to