osip2 编译代码块错误
osip2 compiling codeblocks errors
我正在尝试 运行 使用 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 */
};
结构timeval
不是标准的C结构,它起源于Unix世界并在POSIX中被标准化。
在Windows上它是在<winsock2.h>
头文件中定义的(因为它被select
"network"函数使用,更多信息见this struct timeval
reference on MSDN) .
由于在 <winsock2.h>
之后包含 中使用的结构,因此会出现错误。最简单的解决方案是重新排列包含文件的顺序。
我正在尝试 运行 使用 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 */
};
结构timeval
不是标准的C结构,它起源于Unix世界并在POSIX中被标准化。
在Windows上它是在<winsock2.h>
头文件中定义的(因为它被select
"network"函数使用,更多信息见this struct timeval
reference on MSDN) .
由于在 <winsock2.h>
之后包含 中使用的结构,因此会出现错误。最简单的解决方案是重新排列包含文件的顺序。