This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Redefinition of struct timeval

\components\iot\socket\api\socket_api.h contains a definition for 'struct timeval' that conflicts with \arm-eabi\sys-include\sys\_timeval.h

It creates a conflict with including \arm-eabi\sys-include\sys\time.h:

\arm-eabi\sys-include\sys\time.h
-> includes \arm-eabi\sys-include\sys\_timeval.h
-> defines struct timeval
 -> includes \arm-eabi\sys-include\sys\types.h
   -> includes \components\iot\socket\api\sys\select.h
-> includes \components\iot\socket\api\socket_api.h
-> defines struct timeval

Any suggestions on working around this?

  • I reproduced this error. I'm not sure why timeval is duplicated in the SDK, but the error has gone when I commented the first line in my example. Another trick to avoid this error - include sys/time.h after SDK's headers and specify -D_TIMEVAL_DEFINED

    // #include <sys/time.h>
    
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>
    
    void foo()
    {
        struct timeval tv;
        select(0, 0, 0, 0, &tv);
    }
    

Related