OSIP2编译CodeBlocks错误

osip2 compiling codeblocks errors

本文关键字:错误 CodeBlocks 编译 OSIP2      更新时间:2023-10-16

我正在尝试使用OSIP2库版本5.0.0运行一个简单的程序。这是我的代码,我有一些我无法弄清楚的错误。我正在使用CodeBlocks。

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <osip2/osip.h>
#include <osipparser2/osip_parser.h>
#include <string.h>
#include <winsock2.h>
int main() {
  int i;    osip_t *osip;   i=osip_init(&osip);     if (i!=0)     return -1; }

错误:

||=== Build: Debug in cos2 (compiler: GNU GCC Compiler) ===|
..libosip2-5.0.0libosip2-5.0.0includeosip2osip.h|211|error: field 'timer_a_start' has incomplete type 'timeval'|
..libosip2-5.0.0libosip2-5.0.0includeosip2osip.h|213|error: field 'timer_b_start' has incomplete type 'timeval'|
..libosip2-5.0.0libosip2-5.0.0includeosip2osip.h|215|error: field 'timer_d_start' has incomplete type 'timeval'|
..libosip2-5.0.0libosip2-5.0.0includeosip2osip.h|232|error: field 'timer_e_start' has incomplete type 'timeval'|
..libosip2-5.0.0libosip2-5.0.0includeosip2osip.h|234|error: field 'timer_f_start' has incomplete type 'timeval'|
..libosip2-5.0.0libosip2-5.0.0includeosip2osip.h|236|error: field 'timer_k_start' has incomplete type 'timeval'|
..libosip2-5.0.0libosip2-5.0.0includeosip2osip.h|254|error: field 'timer_g_start' has incomplete type 'timeval'|
..libosip2-5.0.0libosip2-5.0.0includeosip2osip.h|256|error: field 'timer_h_start' has incomplete type 'timeval'|
..libosip2-5.0.0libosip2-5.0.0includeosip2osip.h|258|error: field 'timer_i_start' has incomplete type 'timeval'|
..libosip2-5.0.0libosip2-5.0.0includeosip2osip.h|273|error: field 'timer_j_start' has incomplete type 'timeval'|
..libosip2-5.0.0libosip2-5.0.0includeosip2osip.h|294|error: field 'srv_is_broken' has incomplete type 'timeval'|
..libosip2-5.0.0libosip2-5.0.0includeosip2osip.h|536|error: field 'start' has incomplete type 'timeval'|
C:UsersemergencyDocumentsanalizercos2main.cpp|8|error: '::main' must return 'int'|
C:UsersemergencyDocumentsanalizercos2main.cpp||In function 'int main()':|
C:UsersemergencyDocumentsanalizercos2main.cpp|16|error: cannot convert 'osip_message_t** {aka osip_message**}' to 'osip_t** {aka osip**}' for argument '1' to 'int osip_init(osip_t**)'|
||=== Build failed: 14 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

库中显示代码的部分的错误:

  struct osip_ict {
    int timer_a_length;                           /**< Timer A A=T1, A=2xT1... (unreliable only) */
    struct timeval timer_a_start;                 /**< Timer A (retransmission) */
    int timer_b_length;                           /**< Timer B B = 64* T1 */
    struct timeval timer_b_start;                 /**< Timer B (fire when transaction timeout) */
    int timer_d_length;                           /**< Timer D D >= 32s for unreliable tr (or 0) */
    struct timeval timer_d_start;                 /**< Timer D */
    char *destination;                            /**< IP used to send requests */
    int port;                                     /**< port of next hop */
  };

结构timeval不是标准C结构,它起源于Unix World,并在POSIX中进行标准化。

在Windows上,它在<winsock2.h>标头文件中定义(因为它是由select"网络"函数使用的,请参见MSDN上的struct timeval参考,以获取更多信息)。

由于您包括<winsock2.h> <osip2osip.h>中使用的结构,因此您会收到错误。最简单的解决方案是重新排列您的包含文件的顺序。