title: Is there a way to get the value of __LINE__ on one line and use that value on other lines?
body: <p>Essentially, I want to do this:</p>
  
  <pre><code>#include "foo.h"
  #include "bar.h"
  static const unsigned line_after_includes = __LINE__;
  
  int main()
  {
      foo(line_after_includes);
      bar(line_after_includes);
      return 0;
  }
  </code></pre>
  
  <p>Except like this:</p>
  
  <pre><code>#include "foo.h"
  #include "bar.h"
  #define LINE_AFTER_INCLUDES __LINE__
  
  int main()
  {
      FOO(LINE_AFTER_INCLUDES);
      BAR(LINE_AFTER_INCLUDES);
      return 0;
  }
  </code></pre>
  
  <p>Is it possible to make <code>LINE_AFTER_INCLUDES</code> expand to the value of <code>__LINE__</code> on the line on which <code>LINE_AFTER_INCLUDES</code> was defined, so I can use it with other macros later? I would just use a variable like in the first code snippet, but I need the value as an integer literal, because I will be using it in a switch statement. The alternative is to do</p>
  
  <pre><code>    #define LINE_AFTER_INCLUDES 3 // MAKE SURE THIS IS ON LINE IT'S DEFINED AS!!!
  </code></pre>
  
  <p>which is ugly and harder to maintain. I would settle for that, but I will be doing something a bit more complex than this example...</p>