When I use the following code to perform an action within 1 second, I get Visual Studio warning C4101: warning C4101: "highResClock": local variable without links. I don't understand why I get this warning when I use highResClock twice after declaring it.
chrono::high_resolution_clock highResClock; chrono::duration<int, ratio<1, 1> > dur(1); chrono::time_point<chrono::high_resolution_clock> end = highResClock.now() + dur; while (highResClock.now() < end) { // do something repeatedly for 1 second }
Edit: It appears that the warning from Visual Studio is due to the fact that std :: chrono :: high_resolution_clock :: now () is a static function. The highResClock variable is not needed for now () access, although this is a special method that I decided to use. Visual Studio seems to interpret this as not using a variable. When I use the following, I no longer receive any warnings:
chrono::duration<int, ratio<1, 1> > dur(1); chrono::time_point<chrono::high_resolution_clock> end = chrono::high_resolution_clock::now() + dur; while (chrono::high_resolution_clock::now() < end) { // do nothing }
source share