cppcheck

Recommended way to track down array out-of-bound access/write in C program

寵の児 提交于 2019-11-26 21:14:58
问题 Consider writing implementation for some not-so-obvious algorithm in C. For example let it be recursive quicksort, that I have found in K. N. King's "C Programming: A Modern Approach, 2nd Edition" book, that it's available from here. The most interesting part consist of two following definitions: void quicksort(int a[], int low, int high) { int middle; if (low >= high) return; middle = split(a, low, high); quicksort(a, low, middle - 1); quicksort(a, middle + 1, high); } int split(int a[], int

c++, usleep() is obsolete, workarounds for Windows/MingW?

为君一笑 提交于 2019-11-26 18:50:45
I already found out with another question that Windows/MingW doesn't provide the nanosleep() and setitimer() alternatives to the obsolete usleep(). But my goal is to fix all warnings that cppcheck gives me, including the usleep() style warnings. So, is there a workaround to somehow avoid usleep() on Windows without using cygwin or installing loads of new dependencies/libraries? Thanks. usleep() works with microseconds. In windows for getting microsecond precesion you should use QueryPerformanceCounter() winapi function. Here you can find how get that precesion using it. I used this code from

c++, usleep() is obsolete, workarounds for Windows/MingW?

走远了吗. 提交于 2019-11-26 06:37:15
问题 I already found out with another question that Windows/MingW doesn\'t provide the nanosleep() and setitimer() alternatives to the obsolete usleep(). But my goal is to fix all warnings that cppcheck gives me, including the usleep() style warnings. So, is there a workaround to somehow avoid usleep() on Windows without using cygwin or installing loads of new dependencies/libraries? Thanks. 回答1: usleep() works with microseconds. In windows for getting microsecond precesion you should use