digitalmars.D.learn - How include header file?
- Injeckt (3/3) Sep 07 2022 I need to include this Ws2tcpip.h header file to my project. How
- H. S. Teoh (14/17) Sep 07 2022 If that's the only function you need, you can just copy the declaration
- Injeckt (5/23) Sep 07 2022 It doesn't work. "Reference to an unresolved external symbol
- Injeckt (3/6) Sep 07 2022 No, it doesn't work. Jesus I need to figure out how to add
- Steven Schveighoffer (4/37) Sep 07 2022 On windows, it might have different versions based on character width.
- Loara (3/36) Sep 07 2022 You need to link the DLL to your project. Which DLL contains the
- Injeckt (2/10) Sep 07 2022 ws2_32.dll
- Mike Parker (5/15) Sep 07 2022 https://github.com/dlang/dmd/blob/master/druntime/src/core/sys/windows/w...
- Injeckt (2/18) Sep 07 2022 Thank you so much. Now It works!
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.
Sep 07 2022
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 -- The volume of a pizza of thickness a and radius z can be described by the following formula: pi zz a. -- Wouter Verhelst
Sep 07 2022
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: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.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
Sep 07 2022
On Wednesday, 7 September 2022 at 20:23:03 UTC, Injeckt wrote:_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.No, it doesn't work. Jesus I need to figure out how to add WS2tcpip.h
Sep 07 2022
On 9/7/22 4:23 PM, Injeckt wrote:On Wednesday, 7 September 2022 at 19:38:52 UTC, H. S. Teoh wrote:On windows, it might have different versions based on character width. Don't have time right now to look it up on my windows system. -SteveOn Wed, Sep 07, 2022 at 06:11:14PM +0000, Injeckt via Digitalmars-d-learn wrote: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.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
Sep 07 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:You need to link the DLL to your project. Which DLL contains the definiton of `inet_ntop`?On Wed, Sep 07, 2022 at 06:11:14PM +0000, Injeckt via Digitalmars-d-learn wrote: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.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
Sep 07 2022
On Wednesday, 7 September 2022 at 22:57:53 UTC, Loara wrote:On Wednesday, 7 September 2022 at 20:23:03 UTC, Injeckt wrote:ws2_32.dllOn Wednesday, 7 September 2022 at 19:38:52 UTC, H. S. Teoh wrote:You need to link the DLL to your project. Which DLL contains the definiton of `inet_ntop`?On Wed, Sep 07, 2022 at 06:11:14PM +0000, Injeckt via Digitalmars-d-learn wrote:
Sep 07 2022
On Wednesday, 7 September 2022 at 20:23:03 UTC, Injeckt wrote:Win32 API functions need to be `extern(Windows)`.Convert it to D: extern(C) const(char)* inet_ntop(int af, const(void)* src, char* dst, socklen_t size);https://github.com/dlang/dmd/blob/master/druntime/src/core/sys/windows/winsock2.d#L17 `alias socklen_t = int`You probably also need: alias socklen_t = ...;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`.
Sep 07 2022
On Wednesday, 7 September 2022 at 23:01:34 UTC, Mike Parker wrote:On Wednesday, 7 September 2022 at 20:23:03 UTC, Injeckt wrote:Thank you so much. Now It works!Win32 API functions need to be `extern(Windows)`.Convert it to D: extern(C) const(char)* inet_ntop(int af, const(void)* src, char* dst, socklen_t size);https://github.com/dlang/dmd/blob/master/druntime/src/core/sys/windows/winsock2.d#L17 `alias socklen_t = int`You probably also need: alias socklen_t = ...;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`.
Sep 07 2022