Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

struct ip_mqreq is redefined #8214

Closed
p5pRT opened this issue Nov 18, 2005 · 6 comments
Closed

struct ip_mqreq is redefined #8214

p5pRT opened this issue Nov 18, 2005 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 18, 2005

Migrated from rt.perl.org#37708 (status was 'resolved')

Searchable as RT37708$

@p5pRT
Copy link
Author

p5pRT commented Nov 18, 2005

From ThomasKratz@web.de

Created by ThomasKratz@WEB.DE

win32sck.c includes winsock.h (Winsock Version 1.1) and
ws2spi.h (Winsock version 2.0). The latter includes winsock2.h.

The IP_ constants for winsock2.h are in ws2tcpip.h which is not included
anywhere.

If you now try to include ws2tcpip.h for another module
(I needed it for IO​::Socket​::Multicast) you will get an error
stating that a struct ip_mqreq is redefined, which is correct,
because it is already defined in winsock.h
(included via perl.h and sys/socket.h)

As far as I can judge *either* winsock.h *or* winsock2.h should be used.
Not a mixture of both.

Thomas

Perl Info

Flags:
    category=core
    severity=high

Site configuration information for perl v5.8.7:

Configured by TOMK at Fri Nov 18 11:04:41 2005.

Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
  Platform:
    osname=MSWin32, osvers=5.1, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cl', ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT  -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX',
    optimize='-MD -Zi -DNDEBUG -O1',
    cppflags='-DWIN32'
    ccversion='12.00.8168', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf  -libpath:"c:\perl\lib\CORE"  -machine:x86'
    libpth=\lib
    libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib msvcrt.lib
    perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
    gnulibc_version='undef'
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf  -libpath:"c:\perl\lib\CORE"  -machine:x86'

Locally applied patches:
    


@INC for perl v5.8.7:
    c:/perl/lib
    c:/perl/site/lib
    .


Environment for perl v5.8.7:
    CYGWIN=ntsec tty
    HOME=%HOMEDRIVE%%HOMEPATH%
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;P:\ABT\SIRONCS\PROD\BIN;P:\ABT\ZEIDON32.RUN\BIN;C:\Programme\Microsoft SQL Server\80\Tools\BINN;C:\Programme\Reflection;C:\NUTCROOT\bin;C:\NUTCROOT\bin\x11;C:\NUTCROOT\mksnt;D:\Programme\Support Tools\;D:\Programme\Subversion\bin;D:\programme\cygwin\bin;C:\Programme\Reuters\Common\Login;C:\Programme\Reuters\TIBRV\BIN;C:\PROGRA~1\IBM\SQLLIB\BIN;C:\PROGRA~1\IBM\SQLLIB\FUNCTION;C:\Programme\Microsoft Visual Studio\Common\Tools\WinNT;C:\Programme\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Programme\Microsoft Visual Studio\Common\Tools;C:\Programme\Microsoft Visual Studio\VC98\bin;c:\perl\bin
    PERL_BADLANG (unset)
    SHELL=C:\NUTCROOT\mksnt\sh.exe

______________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193


@p5pRT
Copy link
Author

p5pRT commented Nov 21, 2005

From guest@guest.guest.xxxxxxxx

[ThomasKratz@​web.de - Fri Nov 18 07​:20​:03 2005]​:

Sorry for the missing subject. I had to copy/paste this to another mail
program and forgot to copy the subject as well.

Reading my own error report I feel I should clarify a bit (note to
myself​: never file an error report in a hurry).

I am trying to build IO​::Socket​::Multicast 1.02 on perl 5.8.7 under Win32.
The build was ok under 5.8.4 but the tests fail under 5.8.7.

This is due to wrongly set constants defined in Winsock.h. (for example
IP_ADD_MEMBERSHIP).

Perl is compiled to use winsock2 (via ws2spi.h), but perl.h includes
winsock.h (via win32.h). As a result extensions built this way will use
the winsock 1.1 constants instead of the correct constants from
ws2tcpip.h which is not included anywhere.

Including it in the extensions XS code will result in errors due to
redefined structs.

A workaround for IO​::Socket​::Multicast will be supplying the correct
constants in the XS code. But this should better be resolved by
eliminating winsock 1.1 (winsock.h) altogether.

Thomas

This is a bug report for perl from ThomasKratz@​WEB.DE,
generated with the help of perlbug 1.35 running under perl v5.8.7.

-----------------------------------------------------------------
[Please enter your report here]

win32sck.c includes winsock.h (Winsock Version 1.1) and
ws2spi.h (Winsock version 2.0). The latter includes winsock2.h.

The IP_ constants for winsock2.h are in ws2tcpip.h which is not
included
anywhere.

If you now try to include ws2tcpip.h for another module
(I needed it for IO​::Socket​::Multicast) you will get an error
stating that a struct ip_mqreq is redefined, which is correct,
because it is already defined in winsock.h
(included via perl.h and sys/socket.h)

As far as I can judge *either* winsock.h *or* winsock2.h should be
used.
Not a mixture of both.

Thomas

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags​:
category=core
severity=high
---
Site configuration information for perl v5.8.7​:

Configured by TOMK at Fri Nov 18 11​:04​:41 2005.

Summary of my perl5 (revision 5 version 8 subversion 7) configuration​:
Platform​:
osname=MSWin32, osvers=5.1, archname=MSWin32-x86-multi-thread
uname=''
config_args='undef'
hint=recommended, useposix=true, d_sigaction=undef
usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler​:
cc='cl', ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32
-D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT
-DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX',
optimize='-MD -Zi -DNDEBUG -O1',
cppflags='-DWIN32'
ccversion='12.00.8168', gccversion='', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
ivtype='long', ivsize=4, nvtype='double', nvsize=8,
Off_t='__int64', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries​:
ld='link', ldflags ='-nologo -nodefaultlib -debug -opt​:ref,icf
-libpath​:"c​:\perl\lib\CORE" -machine​:x86'
libpth=\lib
libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib
odbc32.lib odbccp32.lib msvcrt.lib
perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib
version.lib odbc32.lib odbccp32.lib msvcrt.lib
libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
gnulibc_version='undef'
Dynamic Linking​:
dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug
-opt​:ref,icf -libpath​:"c​:\perl\lib\CORE" -machine​:x86'

Locally applied patches​:

---
@​INC for perl v5.8.7​:
c​:/perl/lib
c​:/perl/site/lib
.

---
Environment for perl v5.8.7​:
CYGWIN=ntsec tty
HOME=%HOMEDRIVE%%HOMEPATH%
LANG (unset)
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)

PATH=C​:\WINDOWS\system32;C​:\WINDOWS;C​:\WINDOWS\System32\Wbem;P​:\ABT\SIRONCS\PROD\BIN;P​:\ABT\ZEIDON32.RUN\BIN;C​:\Programme\Microsoft

SQL

Server\80\Tools\BINN;C​:\Programme\Reflection;C​:\NUTCROOT\bin;C​:\NUTCROOT\bin\x11;C​:\NUTCROOT\mksnt;D​:\Programme\Support

Tools\;D​:\Programme\Subversion\bin;D​:\programme\cygwin\bin;C​:\Programme\Reuters\Common\Login;C​:\Programme\Reuters\TIBRV\BIN;C​:\PROGRA1\IBM\SQLLIB\BIN;C​:\PROGRA1\IBM\SQLLIB\FUNCTION;C​:\Programme\Microsoft

Visual Studio\Common\Tools\WinNT;C​:\Programme\Microsoft Visual
Studio\Common\MSDev98\Bin;C​:\Programme\Microsoft Visual
Studio\Common\Tools;C​:\Programme\Microsoft Visual
Studio\VC98\bin;c​:\perl\bin
PERL_BADLANG (unset)
SHELL=C​:\NUTCROOT\mksnt\sh.exe

______________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail​: http​://f.web.de/?mc=021193

@p5pRT
Copy link
Author

p5pRT commented Nov 21, 2005

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Nov 22, 2005

From @jandubois

On Mon, 21 Nov 2005, Guest via RT wrote​:

[ThomasKratz@​web.de - Fri Nov 18 07​:20​:03 2005]​:

I am trying to build IO​::Socket​::Multicast 1.02 on perl 5.8.7 under Win32.
The build was ok under 5.8.4 but the tests fail under 5.8.7.

This is due to wrongly set constants defined in Winsock.h. (for example
IP_ADD_MEMBERSHIP).

Perl is compiled to use winsock2 (via ws2spi.h), but perl.h includes
winsock.h (via win32.h). As a result extensions built this way will use
the winsock 1.1 constants instead of the correct constants from
ws2tcpip.h which is not included anywhere.

Including it in the extensions XS code will result in errors due to
redefined structs.

A workaround for IO​::Socket​::Multicast will be supplying the correct
constants in the XS code. But this should better be resolved by
eliminating winsock 1.1 (winsock.h) altogether.

I think this analysis is correct (except that it is win32/include/sys/socket.h
that includes winsock.h, not win32/win32.h). I've noticed one problem though​:

If perl.h unconditionally includes winsock2.h then you get
compilation errors in XS code that already included windows.h
without defining the WIN32_LEAN_AND_MEAN symbol first. One such
module is win32/ext/Win32/Win32.xs in the Perl core itself. Adding
WIN32_LEAN_AND_MEAN to Win32.xs would in turn require adding a
whole bunch of other #include statements as the module uses various
other Windows APIs that won't be included under the
WIN32_LEAN_AND_MEAN setting.

I believe that most modules that do this will not be using socket
functions, so I decided to *not* include winsock2.h if winsock.h has
already been loaded. I am feeling a bit uneasy about this though, but
can't think of a better solution that wouldn't break existing modules.

There are also references to winsock.h in ext/Errno/Errno_pm.PL, but as
far as I can tell there is no reason to change them to winsock2.h.

Cheers,
-Jan

Inline Patch
--- perl/5.8.7/win32/include/sys/socket.h.~1~   Mon Nov 21 21:04:43 2005
+++ perl/5.8.7/win32/include/sys/socket.h       Mon Nov 21 21:04:43 2005
@@ -15,7 +15,11 @@
 #  define Win32_Winsock
 #endif
 #include <windows.h>
-#include <winsock.h>
+
+/* Too late to include winsock2.h if winsock.h has already been loaded */
+#ifndef _WINSOCKAPI_
+#  include <winsock2.h>
+#endif

 #include "win32.h"

End of Patch.

@p5pRT
Copy link
Author

p5pRT commented Nov 22, 2005

From @Tux

On Mon, 21 Nov 2005 21​:35​:51 -0800, "Jan Dubois" <jand@​ActiveState.com> wrote​:

On Mon, 21 Nov 2005, Guest via RT wrote​:

[ThomasKratz@​web.de - Fri Nov 18 07​:20​:03 2005]​:

I am trying to build IO​::Socket​::Multicast 1.02 on perl 5.8.7 under Win32.
The build was ok under 5.8.4 but the tests fail under 5.8.7.

Thanks, I have applied this patch to *blead* in change #26189
It's up to Nicholas to put it in maint

This is due to wrongly set constants defined in Winsock.h. (for example
IP_ADD_MEMBERSHIP).

Perl is compiled to use winsock2 (via ws2spi.h), but perl.h includes
winsock.h (via win32.h). As a result extensions built this way will use
the winsock 1.1 constants instead of the correct constants from
ws2tcpip.h which is not included anywhere.

Including it in the extensions XS code will result in errors due to
redefined structs.

A workaround for IO​::Socket​::Multicast will be supplying the correct
constants in the XS code. But this should better be resolved by
eliminating winsock 1.1 (winsock.h) altogether.

I think this analysis is correct (except that it is
win32/include/sys/socket.h that includes winsock.h, not win32/win32.h).
I've noticed one problem though​:

If perl.h unconditionally includes winsock2.h then you get
compilation errors in XS code that already included windows.h
without defining the WIN32_LEAN_AND_MEAN symbol first. One such
module is win32/ext/Win32/Win32.xs in the Perl core itself. Adding
WIN32_LEAN_AND_MEAN to Win32.xs would in turn require adding a
whole bunch of other #include statements as the module uses various
other Windows APIs that won't be included under the
WIN32_LEAN_AND_MEAN setting.

I believe that most modules that do this will not be using socket
functions, so I decided to *not* include winsock2.h if winsock.h has
already been loaded. I am feeling a bit uneasy about this though, but
can't think of a better solution that wouldn't break existing modules.

There are also references to winsock.h in ext/Errno/Errno_pm.PL, but as
far as I can tell there is no reason to change them to winsock2.h.

Cheers,
-Jan

--- perl/5.8.7/win32/include/sys/socket.h.1 Mon Nov 21 21​:04​:43 2005
+++ perl/5.8.7/win32/include/sys/socket.h Mon Nov 21 21​:04​:43 2005
@​@​ -15,7 +15,11 @​@​
# define Win32_Winsock
#endif
#include <windows.h>
-#include <winsock.h>
+
+/* Too late to include winsock2.h if winsock.h has already been loaded */
+#ifndef _WINSOCKAPI_
+# include <winsock2.h>
+#endif

#include "win32.h"

End of Patch.

--
H.Merijn Brand Amsterdam Perl Mongers (http​://amsterdam.pm.org/)
using Perl 5.6.2, 5.8.0, 5.8.5, & 5.9.2 on HP-UX 10.20, 11.00 & 11.11,
AIX 4.3 & 5.2, SuSE 9.2 & 9.3, and Cygwin. http​://www.cmve.net/~merijn
Smoking perl​: http​://www.test-smoke.org, perl QA​: http​://qa.perl.org
reports to​: smokers-reports@​perl.org, perl-qa@​perl.org

@p5pRT
Copy link
Author

p5pRT commented May 22, 2008

p5p@spam.wizbit.be - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant