AIX 7.2 GLib-GObject 信号传入无效

AIX 7.2 GLib-GObject signal incoming is invalid

我对 Linux 工具箱中的 glib2.56.1-2 有疑问。我找到了简单的 TCP 服务器示例:

int main (int argc, char *argv[])
{
  GError * error = NULL;

  /* create the new socketservice */
  GSocketService* service = g_socket_service_new ();

  /* connect to the port */
  struct sockaddr_in serv_addr;
  memset(&serv_addr, 0x0, sizeof(serv_addr));
  serv_addr.sin_family = AF_INET;
  serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  serv_addr.sin_port = htons(8000);

  g_socket_listener_add_address ((GSocketListener*)service,
    g_socket_address_new_from_native(&serv_addr, sizeof(serv_addr)),
                                     G_SOCKET_TYPE_STREAM,
                                     G_SOCKET_PROTOCOL_TCP,
                                     NULL,
                                     NULL,
                                     &error);

  /* listen to the 'incoming' signal */
  g_signal_connect (service,
                "incoming",
                G_CALLBACK (incoming_callback),
                NULL);

  /* start the socket service */
  g_socket_service_start (service);

  /* enter mainloop */
  g_print ("Waiting for client!\n");
  GMainLoop *loop = g_main_loop_new(NULL, FALSE);
  g_main_loop_run(loop);

  return 0;
}

但它给了我以下警告:

(process:9633862): GLib-GObject-WARNING **: 12:48:11.025: gsignal.c:2523: signal 'incoming' is invalid for instance '110015730' of type 'GSocketService'

连接似乎已打开,但由于您在上面看到的信号警告,无法处理传入数据。你有什么想法吗?

问候,Jiri。

我从链接器标志中删除了 -Wl,-G。效果很好。谢谢大家