Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having an error in defining usleep function and std::chrono::monotonic_clock #2

Open
Zeinab-E opened this issue Jul 24, 2021 · 2 comments

Comments

@Zeinab-E
Copy link

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.

@chanho-code
Copy link
Owner

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)

@AbhiKhoyani
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants