#MSYS2 上で各種パッケージを更新してから Gauche をビルドしようとしたらエラーになる……と思ったら inet_pton と inet_ntop の定義が MinGW 側で用意されるようになったので Gauche 内の定義とぶつかってました。
##ifdefで判断する方法あるかな? MINGW64_VERSION_MAJOR とか見ればいいんかな。
#inet_ntop と inet_pton はマクロとして定義されているのでそれを直接使えます。 それぞれ InetPtonA (または InetPtonW) と InetNtopA (または InetNtopW) の別名として定義されています。
#diff --git a/ext/net/gauche-net.h b/ext/net/gauche-net.h
index 91e15ca..f70004b 100644
--- a/ext/net/gauche-net.h
+++ b/ext/net/gauche-net.h
@@ -82,8 +82,12 @@ struct sockaddr_un {
unsigned short sun_family;
char sun_path[108];
};
+
+#if !defined(inet_pton)
int inet_pton(int af, const char *src, void *dst);
const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
+#endif
+
#define MSG_WAITALL 0x8
#ifdef HAVE_IPV6
#define IPV6_V6ONLY 27
diff --git a/ext/net/net.c b/ext/net/net.c
index c41fe6e..6025d80 100644
--- a/ext/net/net.c
+++ b/ext/net/net.c
@@ -746,7 +746,7 @@ ScmObj Scm_SocketIoctl(ScmSocket *s, u_long request, ScmObj data)
/*==================================================================
* Windows/MinGW compatibility layer
*/
-#if defined(GAUCHE_WINDOWS)
+#if defined(GAUCHE_WINDOWS) && !defined(inet_pton)
int inet_pton(int af, const char *src, void *dst)
{
#試してないけどこんな感じでどう?
#すいません、勘違いです。 InetNtopA が inet_ntop の別名として定義されてました。
#(提示して頂いたパッチの inet_pton のところを InetPtonA に置き換えればコンパイルできました。)
#InetNtopAはUNICODEの設定が何であれ定義されますか?
#diff --git a/ext/net/gauche-net.h b/ext/net/gauche-net.h
index 91e15ca..c6952af 100644
--- a/ext/net/gauche-net.h
+++ b/ext/net/gauche-net.h
@@ -82,8 +82,13 @@ struct sockaddr_un {
unsigned short sun_family;
char sun_path[108];
};
+
+#if !defined(InetNtopA)
+/* This is for older MinGW */
int inet_pton(int af, const char *src, void *dst);
const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
+#endif /* !defined(InetNtopA) */
+
#define MSG_WAITALL 0x8
#ifdef HAVE_IPV6
#define IPV6_V6ONLY 27
diff --git a/ext/net/net.c b/ext/net/net.c
index c41fe6e..cd43737 100644
--- a/ext/net/net.c
+++ b/ext/net/net.c
@@ -745,8 +745,9 @@ ScmObj Scm_SocketIoctl(ScmSocket *s, u_long request, ScmObj data)
/*==================================================================
* Windows/MinGW compatibility layer
+ * Older MinGW lacks inet_pton/ntop.
*/
-#if defined(GAUCHE_WINDOWS)
+#if defined(GAUCHE_WINDOWS) && !defined(InetNtopA)
int inet_pton(int af, const char *src, void *dst)
{
@@ -813,7 +814,7 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t size)
return dst;
#undef ADDR_MAXLEN
}
-#endif /*GAUCHE_WINDOWS*/
+#endif /*defined(GAUCHE_WINDOWS) && !defined(InetNtopA)*/
/*==================================================================
* Initialization
#これでいけたらcommitします
#はい。 UNICODE の設定に影響されません。 そのパッチで通りました。
##ありがとうございます。 念のため ./DIST gen からビルドしなおしてテストもやってみましたがパスしました。