I'm trying to run a simple program with osip2 library version 5.0.0. This is my code, and i'm having some errors that i cant figure out. I'm using 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; }
Errors:
||=== 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)) ===|
the errors showing this part of code in library:
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 */
};
The structure timeval
is not a standard C structure, it originated in the Unix world and is standardized in POSIX.
On Windows it's defined in the <winsock2.h>
header file (because it's used by the select
"network" function, see this struct timeval
reference on MSDN for more information).
Since you include <winsock2.h>
after the structure is used in <osip2\osip.h>
, you get the error. The simplest solution is to rearrange the order of your include files.