d如何包含头文件

原文
因为需要inet_ntop函数,我要包含Ws2tcpip.h头文件.
要复制

const char *inet_ntop(int af, const void *restrict src, char *restrict dst, socklen_t size);

声明为D:

extern(C) const(char)* inet_ntop(int af, const(void)* src, char* dst, socklen_t size);

还需要:

alias socklen_t = ...;

该定义可在系统头文件中找到.也许可以摆脱size_t.
Windows上,它可能具有基于字符宽度的不同版本.
win32接口需要extern(Windows).

alias socklen_t = int

这是链接错误,你需要链接至ws2_32.lib库.

posted @   zjh6  阅读(15)  评论(0编辑  收藏  举报  
努力加载评论中...
点击右上角即可分享
微信分享提示