digitalmars.D - Bug? Error in phobos?
- Regan Heath <regan netmail.co.nz> Sep 20 2007
- Regan Heath <regan netmail.co.nz> Sep 21 2007
- BCS <ao pathlink.com> Sep 21 2007
- Regan Heath <regan netmail.co.nz> Sep 21 2007
- BCS <BCS pathlink.com> Sep 21 2007
- Regan Heath <regan netmail.co.nz> Sep 21 2007
- dickl <dick221z yahoo.com> Sep 25 2007
- TomD <t_demmer_nospam_ web.de> Sep 21 2007
- Regan Heath <regan netmail.co.nz> Sep 21 2007
- Carlos Santander <csantander619 gmail.com> Sep 21 2007
- "Jarrett Billingsley" <kb3ctd2 yahoo.com> Sep 21 2007
- Regan Heath <regan netmail.co.nz> Sep 22 2007
import std.socket;
import std.c.windows.winsock;
pragma(lib, "wsock32.lib");
class IndexPacketReader
{
//static void foo() //works
void foo()
{
ntohl(1); //fails
}
}
void main()
{
new TcpSocket();
//ntohl(1); //works
}
E:\D\src\tmp>dmd bug003.d
E:\D\dmd\bin\..\..\dm\bin\link.exe bug003,,,user32+kernel32/noi;
OPTLINK (R) for Win32 Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved
E:\D\dmd\bin\..\lib\phobos.lib(winsock) Offset 276FEH Record Type 00C3
Error 1: Previous Definition Different : _ntohl 4
--- errorlevel 1
Anyone know what this means?
Regan
Sep 20 2007
Regan Heath wrote:import std.socket; import std.c.windows.winsock; pragma(lib, "wsock32.lib"); class IndexPacketReader { //static void foo() //works void foo() { ntohl(1); //fails } } void main() { new TcpSocket(); //ntohl(1); //works } E:\D\src\tmp>dmd bug003.d E:\D\dmd\bin\..\..\dm\bin\link.exe bug003,,,user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved E:\D\dmd\bin\..\lib\phobos.lib(winsock) Offset 276FEH Record Type 00C3 Error 1: Previous Definition Different : _ntohl 4 --- errorlevel 1 Anyone know what this means?
No-one?? This bug is particularly annoying because it prevents me from calling ntohl, ntohs etc from within a class method. In the end I just wrote my own ntohl functin and called that. Regan
Sep 21 2007
Reply to Regan,Error 1: Previous Definition Different : _ntohl 4 --- errorlevel 1 Anyone know what this means?
from calling ntohl, ntohs etc from within a class method. In the end I just wrote my own ntohl functin and called that.
I don't known why your getting it, but you must have more than one ntohl defined. The linker is finding this so I expect that one is in a lib. Try dropping the pragma (lib) and explictly linking c:\dmd\lib\WS2_32.LIB directly.Regan
Sep 21 2007
BCS wrote:Reply to Regan,Error 1: Previous Definition Different : _ntohl 4 --- errorlevel 1 Anyone know what this means?
from calling ntohl, ntohs etc from within a class method. In the end I just wrote my own ntohl functin and called that.
I don't known why your getting it, but you must have more than one ntohl defined. The linker is finding this so I expect that one is in a lib.
That's what I thought might be happening.Try dropping the pragma (lib) and explictly linking c:\dmd\lib\WS2_32.LIB directly.
No such luck :( E:\D\src\tmp>dmd bug003 e:\d\dmd\lib\ws2_32.lib E:\D\dmd\bin\..\..\dm\bin\link.exe bug003,,,e:\d\dmd\lib\ws2_32.lib+user32+kerne l32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved E:\D\dmd\bin\..\lib\phobos.lib(winsock) Offset 276FEH Record Type 00C3 Error 1: Previous Definition Different : _ntohl 4 --- errorlevel 1 I tried wsock32.lib, ws2_32.lib at prompt, as pragmas, nothing seems to want to link. Regan
Sep 21 2007
Regan Heath wrote:BCS wrote:Reply to Regan,Error 1: Previous Definition Different : _ntohl 4 --- errorlevel 1 Anyone know what this means?
from calling ntohl, ntohs etc from within a class method. In the end I just wrote my own ntohl functin and called that.
I don't known why your getting it, but you must have more than one ntohl defined. The linker is finding this so I expect that one is in a lib.
That's what I thought might be happening.Try dropping the pragma (lib) and explictly linking c:\dmd\lib\WS2_32.LIB directly.
No such luck :(
long shoot: grab a fresh dmd.zip, replace ws2_32.lib. It might be bad.
Sep 21 2007
BCS wrote:Regan Heath wrote:BCS wrote:Reply to Regan,Error 1: Previous Definition Different : _ntohl 4 --- errorlevel 1 Anyone know what this means?
from calling ntohl, ntohs etc from within a class method. In the end I just wrote my own ntohl functin and called that.
I don't known why your getting it, but you must have more than one ntohl defined. The linker is finding this so I expect that one is in a lib.
That's what I thought might be happening.Try dropping the pragma (lib) and explictly linking c:\dmd\lib\WS2_32.LIB directly.
No such luck :(
long shoot: grab a fresh dmd.zip, replace ws2_32.lib. It might be bad.
I get the impression Tom tried it and it gives the same error for him. I'll grab a fresh dmd and give it a go but I wont hold my breath. Regan
Sep 21 2007
Looks like a phobos problem. ntohl can be found in both phobos.lib and wsock32.lib. If you don't link with wsock32.lib, the error relating to ntohl goes away (and creates other problems). std.c.windows.socket has its own version of ntohl. It should either be a unique name or refer to wsock32.lib. Dick BCS wrote:Reply to Regan,Error 1: Previous Definition Different : _ntohl 4 --- errorlevel 1 Anyone know what this means?
from calling ntohl, ntohs etc from within a class method. In the end I just wrote my own ntohl functin and called that.
I don't known why your getting it, but you must have more than one ntohl defined. The linker is finding this so I expect that one is in a lib. Try dropping the pragma (lib) and explictly linking c:\dmd\lib\WS2_32.LIB directly.Regan
Sep 25 2007
Regan Heath Wrote:Regan Heath wrote:import std.socket; import std.c.windows.winsock; pragma(lib, "wsock32.lib"); class IndexPacketReader { //static void foo() //works void foo() { ntohl(1); //fails } } void main() { new TcpSocket(); //ntohl(1); //works } E:\D\src\tmp>dmd bug003.d E:\D\dmd\bin\..\..\dm\bin\link.exe bug003,,,user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved E:\D\dmd\bin\..\lib\phobos.lib(winsock) Offset 276FEH Record Type 00C3 Error 1: Previous Definition Different : _ntohl 4 --- errorlevel 1 Anyone know what this means?
No-one?? This bug is particularly annoying because it prevents me from calling ntohl, ntohs etc from within a class method. In the end I just wrote my own ntohl functin and called that. Regan
It works when you drop the new TcpSocket(). Go figure. It gives me no clue what may be the reason. Ciao TomD
Sep 21 2007
TomD wrote:Regan Heath Wrote:Regan Heath wrote:import std.socket; import std.c.windows.winsock; pragma(lib, "wsock32.lib"); class IndexPacketReader { //static void foo() //works void foo() { ntohl(1); //fails } } void main() { new TcpSocket(); //ntohl(1); //works } E:\D\src\tmp>dmd bug003.d E:\D\dmd\bin\..\..\dm\bin\link.exe bug003,,,user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved E:\D\dmd\bin\..\lib\phobos.lib(winsock) Offset 276FEH Record Type 00C3 Error 1: Previous Definition Different : _ntohl 4 --- errorlevel 1 Anyone know what this means?
calling ntohl, ntohs etc from within a class method. In the end I just wrote my own ntohl functin and called that. Regan
It works when you drop the new TcpSocket(). Go figure. It gives me no clue what may be the reason.
I reckon "new TcpSocket" causes the linker to link something it otherwise wouldn't. That's the extent of my knowledge however :( Regan
Sep 21 2007
Regan Heath escribió:import std.socket; import std.c.windows.winsock; pragma(lib, "wsock32.lib"); class IndexPacketReader { //static void foo() //works void foo() { ntohl(1); //fails } } void main() { new TcpSocket(); //ntohl(1); //works } E:\D\src\tmp>dmd bug003.d E:\D\dmd\bin\..\..\dm\bin\link.exe bug003,,,user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved E:\D\dmd\bin\..\lib\phobos.lib(winsock) Offset 276FEH Record Type 00C3 Error 1: Previous Definition Different : _ntohl 4 --- errorlevel 1 Anyone know what this means? Regan
Can you check if std.socket already has pragma(lib) ? -- Carlos Santander Bernal
Sep 21 2007
"Carlos Santander" <csantander619 gmail.com> wrote in message news:fd18ni$1ucu$1 digitalmars.com...Can you check if std.socket already has pragma(lib) ?
Even if it does I don't think pragma(lib)s work if you only import the file. I think it has to be compiled.
Sep 21 2007
Carlos Santander wrote:Regan Heath escribió: > import std.socket; > import std.c.windows.winsock; > > pragma(lib, "wsock32.lib"); > > class IndexPacketReader > { > //static void foo() //works > void foo() > { > ntohl(1); //fails > } > } > > void main() > { > new TcpSocket(); > //ntohl(1); //works > } > > E:\D\src\tmp>dmd bug003.d > E:\D\dmd\bin\..\..\dm\bin\link.exe bug003,,,user32+kernel32/noi; > OPTLINK (R) for Win32 Release 7.50B1 > Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved > > E:\D\dmd\bin\..\lib\phobos.lib(winsock) Offset 276FEH Record Type 00C3 > Error 1: Previous Definition Different : _ntohl 4 > --- errorlevel 1 > > Anyone know what this means? > > Regan Can you check if std.socket already has pragma(lib) ?
Ok... It does not. In fact "pragma" is not used in phobos at all. Regan
Sep 22 2007









Regan Heath <regan netmail.co.nz> 