windows - Cannot understand this LARGE_INTEGER line -


i'm looking @ code regarding scheduling queryperformancefrequency. can't understand what's going on here. why rvalue wrapped in parenthesis? large_integer struct, initializing require {} instead, totally confused line. queryperformancefrequency returns bool, too.

// initialize resolution of timer large_integer timer::m_freq = (queryperformancefrequency(&timer::m_freq), timer::m_freq); 

the header contains timer struct private member:

static large_integer m_freq; 

it's bad. bad commenters have said.

given queryperformancefrequency should cheap call make, there's little need cache global (static) variable.

do instead.

  1. remove static declaration m_freq variable in class declaration.

  2. initialize m_freq in constructor of timer class.

example:

timer::timer() {     bool result = queryperformancefrequency(&m_freq);      if (result==false)     {         // optional - set error condition.  it's not         // original code handling potential error either     } } 

Comments