Skip Menu |

This queue is for tickets about the Socket CPAN distribution.

Report information
The Basics
Id: 87389
Status: resolved
Priority: 0/
Queue: Socket

People
Owner: Nobody in particular
Requestors: BULKDD [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.002
Fixed in: 2.012



Subject: 2.002 syntax errors on WinCE, interface is a reserved word
pack_ip_mreq and a couple more xsubs in Socket.xs declare variables called "interface". "interface" is macroed defined to "struct" in ole2.h on Windows. On Desktop Windows WIN32_LEAN_AND_MEAN prevents ole2.h from being loaded when windows.h is included. WinCE's headers dont implement WIN32_LEAN_AND_MEAN so ole2.h is included which defined interface to struct. The "struct" causes syntax errors when trying to build Socket for WinCE. Example preprocessed code. Show quoted text
_________________________________________________________ static void XS_Socket_pack_ip_mreq (CV * cv); static void XS_Socket_pack_ip_mreq (CV * cv) { extern int Perl___notused (void); SV **sp = PL_stack_sp; I32 ax = (*PL_markstack_ptr--); SV **mark = PL_stack_base + ax++; I32 items = (I32) (sp - mark); if (items < 1 || items > 2) Perl_croak_xs_usage (cv, "multiaddr, interface=&PL_sv_undef"); { SV *multiaddr = PL_stack_base[ax + (0)]; SV *struct; if (items < 2) struct = &PL_sv_undef; else { struct = PL_stack_base[ax + (1)]; } #line 997 "Socket.xs" { not_here ("pack_ip_mreq"); #line 1026 "Socket.xs" } #line 1374 "Socket.c" }
_________________________________________________________ All variables named interface need to be renamed.
patch attached
Subject: 0001-fix-WinCE-multiple-struct-definition-problem.patch
From 27809ce129af7b865c3dd712df3862c17bf30791 Mon Sep 17 00:00:00 2001 From: Daniel Dragan <bulk88@hotmail.com> Date: Thu, 22 Aug 2013 15:59:53 -0400 Subject: [PATCH] fix WinCE multiple struct definition problem on the CE SDK ws2tcpip.h contains struct definitions from winsock.h, this leads to a syntax error when building for WinCE, on CE, dont include ws2tcpip.h, other headers already have everything Socket needs --- cpan/Socket/Socket.xs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpan/Socket/Socket.xs b/cpan/Socket/Socket.xs index 0690435..bea80bc 100644 --- a/cpan/Socket/Socket.xs +++ b/cpan/Socket/Socket.xs @@ -44,7 +44,7 @@ # include <netinet/tcp.h> #endif -#ifdef WIN32 +#if defined(WIN32) && ! defined(UNDER_CE) # include <ws2tcpip.h> #endif -- 1.8.0.msysgit.0
Applied, will be in next release. Thanks. -- Paul Evans
Applied, will be in next release. Thanks. -- Paul Evans
On Sat Aug 31 19:53:27 2013, PEVANS wrote: Show quoted text
> Applied, will be in next release. > > Thanks.
Did you only apply the patch I have in this thread, or also the variables named "interface" problem which i do not have a patch for? I can't seem to locate a public repo for Socket to check what went into the source code. Socket doesn't have a public repo, right?
On Sun Sep 01 00:22:14 2013, BULKDD wrote: Show quoted text
> Did you only apply the patch I have in this thread, or also the > variables named "interface" problem which i do not have a patch for?
Oh; I see. I didn't realise they were two separate issues. I'll do that one separately. Show quoted text
> I can't seem to locate a public repo for Socket to check what went > into the source code. Socket doesn't have a public repo, right?
bzr branch http://bazaar.leonerd.org.uk/perl/Socket/ -- Paul Evans
Find attached a patch to hopefully fix both these. Let me know how it goes. -- Paul Evans
Subject: rt87389.patch
=== modified file 'Socket.xs' --- Socket.xs 2013-07-28 18:41:16 +0000 +++ Socket.xs 2013-09-01 19:11:31 +0000 @@ -47,7 +47,7 @@ # include <netinet/tcp.h> #endif -#ifdef WIN32 +#if defined(WIN32) && !defined(UNDER_CE) # include <ws2tcpip.h> #endif @@ -331,6 +331,11 @@ #define NIx_NOHOST (1 << 0) #define NIx_NOSERV (1 << 1) +/* On Windows, ole2.h defines a macro called "interface". We don't need that, + * and it will complicate the variables in pack_ip_mreq() etc. (RT87389) + */ +#undef interface + static int not_here(const char *s) @@ -1133,9 +1138,9 @@ } void -pack_ipv6_mreq(multiaddr, interface) +pack_ipv6_mreq(multiaddr, ifindex) SV * multiaddr - unsigned int interface + unsigned int ifindex CODE: { #ifdef HAS_IPV6_MREQ @@ -1150,7 +1155,7 @@ "Socket::pack_ipv6_mreq", (UV)len, (UV)sizeof(mreq.ipv6mr_multiaddr)); Zero(&mreq, sizeof(mreq), char); Copy(multiaddrbytes, &mreq.ipv6mr_multiaddr, sizeof(mreq.ipv6mr_multiaddr), char); - mreq.ipv6mr_interface = interface; + mreq.ipv6mr_interface = ifindex; ST(0) = sv_2mortal(newSVpvn((char *)&mreq, sizeof(mreq))); #else not_here("pack_ipv6_mreq");
On Sun Sep 01 15:12:34 2013, PEVANS wrote: Show quoted text
> Find attached a patch to hopefully fix both these. > > Let me know how it goes.
I now have a Socket.dll. You can close this ticket.
On Tue Sep 03 04:50:15 2013, BULKDD wrote: Show quoted text
> On Sun Sep 01 15:12:34 2013, PEVANS wrote:
> > Find attached a patch to hopefully fix both these. > > > > Let me know how it goes.
> > I now have a Socket.dll. You can close this ticket. >
Patch worked. Someone could say stylistically "#undef interface" is inclean, but whatever.
Released as 2.012 -- Paul Evans