I was told to not include the C headers like <stdio.h>
in a c++ program, but to use <cstdio>
etc. instead. How do I get struct timeval
without including <sys/time.h>
?
Alternative question, is there any C++11 alternative to using select/poll (on a POSIX system)?
The <cstdio>
and similar are C++ variants for the C standard library. <sys/time.h>
is not part of the C standard library at all (it is part of the POSIX interface for certan OS's), so there is no such thing as a C++ specific sys/ctime
, so no, you just have to use the same header-file as in C.
The main reason for having a C style and C++ style header is to apply the extern "C"
to the functions declared in the headerfile. In some systems, it may be required to wrap the function like this:
extern "C" {
#include <sys/time.h>
}
but in my Linux system, it does that in the standard <sys/time.h>
file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With