我试图用osip2库5.0.0版运行一个简单的程序。 这是我的代码,我有一些我无法弄清楚的错误。 我使用的是代码块。
#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.0\libosip2-5.0.0\include\osip2\osip.h|211|error: field 'timer_a_start' has incomplete type 'timeval'|
..\libosip2-5.0.0\libosip2-5.0.0\include\osip2\osip.h|213|error: field 'timer_b_start' has incomplete type 'timeval'|
..\libosip2-5.0.0\libosip2-5.0.0\include\osip2\osip.h|215|error: field 'timer_d_start' has incomplete type 'timeval'|
..\libosip2-5.0.0\libosip2-5.0.0\include\osip2\osip.h|232|error: field 'timer_e_start' has incomplete type 'timeval'|
..\libosip2-5.0.0\libosip2-5.0.0\include\osip2\osip.h|234|error: field 'timer_f_start' has incomplete type 'timeval'|
..\libosip2-5.0.0\libosip2-5.0.0\include\osip2\osip.h|236|error: field 'timer_k_start' has incomplete type 'timeval'|
..\libosip2-5.0.0\libosip2-5.0.0\include\osip2\osip.h|254|error: field 'timer_g_start' has incomplete type 'timeval'|
..\libosip2-5.0.0\libosip2-5.0.0\include\osip2\osip.h|256|error: field 'timer_h_start' has incomplete type 'timeval'|
..\libosip2-5.0.0\libosip2-5.0.0\include\osip2\osip.h|258|error: field 'timer_i_start' has incomplete type 'timeval'|
..\libosip2-5.0.0\libosip2-5.0.0\include\osip2\osip.h|273|error: field 'timer_j_start' has incomplete type 'timeval'|
..\libosip2-5.0.0\libosip2-5.0.0\include\osip2\osip.h|294|error: field 'srv_is_broken' has incomplete type 'timeval'|
..\libosip2-5.0.0\libosip2-5.0.0\include\osip2\osip.h|536|error: field 'start' has incomplete type 'timeval'|
C:\Users\emergency\Documents\analizer\cos2\main.cpp|8|error: '::main' must return 'int'|
C:\Users\emergency\Documents\analizer\cos2\main.cpp||In function 'int main()':|
C:\Users\emergency\Documents\analizer\cos2\main.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 */
};
答案 0 :(得分:1)
结构timeval
不是标准的C结构,它起源于Unix世界,并在POSIX中标准化。
在Windows上,它在<winsock2.h>
头文件中定义(因为它由select
“网络”功能使用,有关详细信息,请参阅this struct timeval
reference on MSDN。)
由于您在<winsock2.h>
中使用结构后包含<osip2\osip.h>
,因此会收到错误消息。最简单的解决方案是重新排列包含文件的顺序。