0

Trying to compile c++ code that was used in Linux with Visual c++. Got error on line:

struct timeval ts;

Can't find timeval structure in Windows. Why?

vico
  • 17,051
  • 45
  • 159
  • 315
  • i saw this , is it included in winsock.h https://learn.microsoft.com/en-us/windows/win32/api/winsock/ns-winsock-timeval – long.kl Jan 22 '22 at 10:16
  • 2
    It's a POSIX (Unix, Linux, macOS) structure. What is the code doing? Perhaps you need to port (rewrite) it for Windows? Or find an existing Windows-port (or another Windows-specific program)? – Some programmer dude Jan 22 '22 at 10:16
  • [there's no `timeval` in C or C++](https://duckduckgo.com/?sites=cppreference.com&q=timeval&ia=web) so obviously it's some platform-specific thing – phuclv Jan 22 '22 at 10:39
  • https://stackoverflow.com/questions/10905892/equivalent-of-gettimeday-for-windows – Hans Passant Jan 22 '22 at 11:21

1 Answers1

0

You can write your own timeval structure according to following links Winsock timeval, Struct timeval in C, and other hits on the network.

MSVC defines this in winsock.h

typedef struct timeval {
    long tv_sec;
    long tv_usec;
} timeval;
Nejc Galof
  • 2,538
  • 3
  • 31
  • 70