title: C++ macro time arithmetic
body: <p>I'm working on a wgl loader and typedef'd each openGL function that I use like this:</p>
  <pre><code>/*Let's say I'm defining n functions*/ 
  typedef return_t (*f1)(params)
  f1 _glFunc1;
  #define glFunc1(params) _glFunc1(params)
  ...
  typedef return_t (*fn)(params)
  fn _glFuncn;
  #define glFuncn(params) _glFuncn(params)
  </code></pre>
  <p>Then to get the definitions of these functions I have to use wglGetProcAddress or GetProcAddress and then cast the result to f1, f2 ...
  I tried to automate the casting with this macro:</p>
  <pre><code>#define GetFuncDef(glFunc) _##glFunc = (f##(__LINE__ - startingLineNumber + 1))GetProcAddress(#glFunc)
  </code></pre>
  <p>Where <code>startingLineNumber</code> is the first line that I use this macro in(in my case it's 22),
  but the preprocessor does not compute <code>__LINE__ - startingLineNumber</code>.</p>
  <p>Is there some way to force it to do so?</p>
  <p>EDIT:
  <code>startingLineNumber</code> isn't a variable, macro etc. It's written out as a literal number in my code. like this:
  <code>#define GetFuncDef(glFunc) _##glFunc = (f##(__LINE__ - 22 + 1))GetProcAddress(#glFunc)</code>, where 22 would be <code>startingLineNumber</code></p>