How include header file?

Mike Parker aldacron at gmail.com
Wed Sep 7 23:01:34 UTC 2022


On Wednesday, 7 September 2022 at 20:23:03 UTC, Injeckt wrote:

>> Convert it to D:
>>
>> 	extern(C) const(char)* inet_ntop(int af, const(void)* src, 
>> char* dst, socklen_t size);

Win32 API functions need to be `extern(Windows)`.

>>
>> You probably also need:
>>
>> 	alias socklen_t = ...;

https://github.com/dlang/dmd/blob/master/druntime/src/core/sys/windows/winsock2.d#L17

`alias socklen_t = int`


>
> It doesn't work. "Reference to an unresolved external symbol 
> _inet_ntop".

That's a linker error. You need to link with `ws2_32.lib`.


More information about the Digitalmars-d-learn mailing list