How include header file?

Loara loara at
Wed Sep 7 22:57:53 UTC 2022

On Wednesday, 7 September 2022 at 20:23:03 UTC, Injeckt wrote:
> On Wednesday, 7 September 2022 at 19:38:52 UTC, H. S. Teoh 
> wrote:
>> On Wed, Sep 07, 2022 at 06:11:14PM +0000, Injeckt via 
>> Digitalmars-d-learn wrote:
>>> I need to include this Ws2tcpip.h header file to my project. 
>>> How can I do this? It's all because I need inet_ntop function 
>>> from this header file.
>> If that's the only function you need, you can just copy the 
>> declaration of inet_ntop into your .d file and mark it as 
>> extern(C). E.g., on my OS it's declared as:
>> 	const char *inet_ntop(int af, const void *restrict src, char 
>> *restrict dst, socklen_t size);
>> Convert it to D:
>> 	extern(C) const(char)* inet_ntop(int af, const(void)* src, 
>> char* dst, socklen_t size);
>> You probably also need:
>> 	alias socklen_t = ...;
>> The definition can be found in your system header files. 
>> Probably you can just get away with size_t.
>> T
> It doesn't work. "Reference to an unresolved external symbol 
> _inet_ntop". I guess I can add my utils.c to my .d project when 
> I compile project and I need write in this file function 
> wrapper of inet_ntop.

You need to link the DLL to your project. Which DLL contains the 
definiton of `inet_ntop`?

More information about the Digitalmars-d-learn mailing list