Having an error in defining usleep function and std::chrono::monotonic_clock
Zeinab-E opened this issue · 2 comments
Hi,
Can you please let me know what usleep function you added in the example?
Since I have got an error by defining the following usleep finction and also got an error in line 181 of mono_inertial_euroc.cc std::chrono::monotonic_clock::time_point time2 = std::chrono::monotonic_clock::now();: which it said "Error (active) E0304 no instance of function template "std::chrono::duration_cast" matches the argument list mono_inertial_euroc"
#include <windows.h>
void usleep(__int64 usec)
{
HANDLE timer;
LARGE_INTEGER ft;
ft.QuadPart = -(10*usec); // Convert to 100 nanosecond interval, negative value indicates relative time
timer = CreateWaitableTimer(NULL, TRUE, NULL);
SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0);
WaitForSingleObject(timer, INFINITE);
CloseHandle(timer);
}
I would greatly appreciate it if you could help me.
Thank you for your interest in my project.
I also used the same "usleep" function (you mentioned).
Try using steady_clock rather than monotonic_clock. (with "COMPILEDWITHC11" in preprocessor definition)
the problem is while building application windows.h is interfering std::max() and std::min() functions, due to which it is raising error. how to tackle it besides mentioned in this thread: https://stackoverflow.com/questions/5004858/why-is-stdmin-failing-when-windows-h-is-included ; because as it's mentioned in here changing at all places is not an optimal solution.