Re: High-Res time and related functions
- Posted by jmduro Aug 07, 2021
- 1066 views
petelomax said...
jmduro said...
ifdef WINDOWS then procedure error_message(sequence msg, atom quit) elsifdef LINUX then error_message("Your hardware does not support hi-res timers.", 1) end ifdef
Does that work??
You're right.error_message is a procedure I define normally in another file.
Here I inserted it at the wrong place. It should be above ifdef WINDOWS.
-------------------------------------------------------------------------------- procedure error_message(sequence msg, atom quit) ifdef WINDOWS then object void = message_box(msg, "Error", MB_ICONERROR+MB_OK+MB_APPLMODAL+MB_SETFOREGROUND) elsifdef LINUX then puts(2, "Error: " & msg & "\n") end ifdef if quit then abort(1) end if end procedure --*------------------------------------------------------* -- reference high resolution timer libraries --*------------------------------------------------------* ifdef WINDOWS then atom k32 = open_dll("kernel32") if k32 = -1 then error_message("kernel32.dll can\'t be opened.", 1) end if atom perf_frq_ = define_c_func(k32, "QueryPerformanceFrequency", {C_UINT}, C_UINT) atom perf_cnt_ = define_c_proc(k32, "QueryPerformanceCounter", {C_UINT}) if (perf_cnt_=-1) or (perf_frq_=-1) then error_message("The current Windows version does not support hi-res timers.", 1) end if
Sorry for the bug.
Jean-Marc