Fix compile error from uv_tcp_init_ex when using older libuv versions
uv_tcp_init_ex was introduced in libuv 1.7.0
@@ -28,6 +28,7 @@ static int luv_new_tcp(lua_State* L) {
luv_ctx_t* ctx = luv_context(L);
lua_settop(L, 1);
handle = (uv_tcp_t*)luv_newuserdata(L, sizeof(*handle));
+#if LUV_UV_VERSION_GEQ(1, 7, 0)
if (lua_isnoneornil(L, 1)) {
ret = uv_tcp_init(ctx->loop, handle);
}
@@ -48,6 +49,9 @@ static int luv_new_tcp(lua_State* L) {
}
ret = uv_tcp_init_ex(ctx->loop, handle, flags);
}
+#else
+ ret = uv_tcp_init(ctx->loop, handle);
+#endif
if (ret < 0) {
lua_pop(L, 1);
return luv_error(L, ret);
