[Issue 17851] New: htonl already defined in phobos64.lib

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Sep 23 03:11:05 UTC 2017


https://issues.dlang.org/show_bug.cgi?id=17851

          Issue ID: 17851
           Summary: htonl already defined in phobos64.lib
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody at puremagic.com
          Reporter: bitworld at qq.com

When building a simple demo for
libevent(https://github.com/D-Programming-Deimos/libevent) on Windows 10 X64, I
got these errors blown:


ws2_32.lib(WS2_32.dll) : error LNK2005: htonl already defined in
phobos64.lib(winsock2_1f3b_225.obj)
ws2_32.lib(WS2_32.dll) : error LNK2005: htons already defined in
phobos64.lib(winsock2_1f3a_22c.obj)
ws2_32.lib(WS2_32.dll) : error LNK2005: ntohl already defined in
phobos64.lib(winsock2_1f3d_225.obj)
ws2_32.lib(WS2_32.dll) : error LNK2005: ntohs already defined in
phobos64.lib(winsock2_1f3c_22c.obj)


I redefined these functions in druntime\src\core\sys\windows\winsock2.d. For
example:

    uint htonl(uint x)
    {
        return bswap(x);
    }

is changed to:
   uint htonl(uint x);

After rebuilding the phobos64.lib, I can eliminate these errors.


Here is a test code:

import std.stdio;
import deimos.event2.event; 
import std.socket;

void main()
{  

    event_base_loopbreak(null);

    InternetAddress addr1 = new InternetAddress("127.0.0.1", 80);
    writeln(addr1.port);
    writeln(addr1.addr);
}

Compiler: dmd v2.076.0/VC++ 2017
OS: Windows 10 x64

--


More information about the Digitalmars-d-bugs mailing list