September 23, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1529

           Summary: using std.socket and calling ntohl in class member
                    causes link failure
           Product: D
           Version: 2.004
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: regan@netmail.co.nz


Using ntohl from std.c.windows.winsock in a class member while also using something from std.socket causes linking errors.

//TEST CASE

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 

Removing the "new TcpSocket()" makes it link.
Making the class member static makes it link.
Calling it from main makes it link.

I have tried removing the pragma and specifying the .lib in the command line, no change.  I have tried uising ws2_32.lib instead of wsock32.lib, no change.

In my case I wrote my own ntohl to get past the problem.


-- 

August 24, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=1529


Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |thecybershadow@gmail.com
         Resolution|                            |WORKSFORME


--- Comment #1 from Vladimir Panteleev <thecybershadow@gmail.com> 2011-08-23 19:12:21 PDT ---
Seems to work with DMD 2.054.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------