我使用 libstrophe 版本 0.8.9 来开发我的 xmpp 客户端。
这是我的 xmmp 客户端连接到服务器的 xmmp 功能
#include <strophe.h>
int xmpp_connect(void)
{
xmpp_ctx_t *ctx;
xmpp_conn_t *conn;
xmpp_log_t *log;
int sta;
static int retry = 0;
xmpp_initialize();
log = xmpp_get_default_logger(XMPP_LEVEL_DEBUG);
ctx = xmpp_ctx_new(NULL, log);
conn = xmpp_conn_new(ctx);
xmpp_conn_set_jid(conn, cur_xmmp_con.jid);
xmpp_conn_set_pass(conn, cur_xmmp_con.password);
#if 1
if (!tls_start(conn->tls))
{
xmpp_debug(conn->ctx, "xmpp", "Couldn't start TLS! error %d", tls_error(conn->tls));
tls_free(conn->tls);
conn->tls = NULL;
conn->tls_failed = 1;
/* failed tls spoils the connection, so disconnect */
xmpp_disconnect(conn);
}
else
{
conn->secured = 1;
conn_prepare_reset(conn, NULL);
conn_open_stream(conn);
}
#endif
//
sta = xmpp_connect_client(conn, NULL, 0, conn_handler, ctx);
xmpp_run(ctx);
return 0;
}
我收到了这些错误
./src/test_xmpp.c:62:21: error: dereferencing pointer to incomplete type
if (!tls_start(conn->tls))
^
../src/test_xmpp.c:64:18: error: dereferencing pointer to incomplete type
xmpp_debug(conn->ctx, "xmpp", "Couldn't start TLS! error %d", tls_error(conn->tls));
^
../src/test_xmpp.c:64:79: error: dereferencing pointer to incomplete type
xmpp_debug(conn->ctx, "xmpp", "Couldn't start TLS! error %d", tls_error(conn->tls));
^
../src/test_xmpp.c:65:16: error: dereferencing pointer to incomplete type
tls_free(conn->tls);
^
../src/test_xmpp.c:66:7: error: dereferencing pointer to incomplete type
conn->tls = NULL;
^
../src/test_xmpp.c:67:7: error: dereferencing pointer to incomplete type
conn->tls_failed = 1;
^
../src/test_xmpp.c:73:7: error: dereferencing pointer to incomplete type
conn->secured = 1;
虽然这些变量存在于这个文件中https://github.com/metajack/libstrophe/blob/master/src/common.h
我的代码或 libstrophe 有什么问题?