title: Creating macro using __LINE__ for different variable names
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1597007/creating-c-macro-with-and-line-token-concatenation-with-positioning-macr">Creating C macro with ## and <strong>LINE</strong> (token concatenation with positioning macro)</a>  </p>
  </blockquote>
  
  
  
  <p>I am trying to use the <code>__LINE__</code> macro to generate different variable names. I have a scoped benchmark class called Benchmark(located in the utils namespace) and it's constructor takes a string. Here is the macro definition I have created:</p>
  
  <pre><code>#define BENCHMARK_SCOPE utils::Benchmark bm##__LINE__(std::string(__FUNCTION__))
  </code></pre>
  
  <p>Unfortunately this causes the following error:</p>
  
  <p><code>&lt;some_file_name&gt;(59): error C2374: 'bm__LINE__' : redefinition; multiple initialization</code></p>
  
  <p>This leads me to the conclusion the <code>__LINE__</code> macros does not get expanded. I have created my macross according to <a href="https://stackoverflow.com/a/1675203/812912">this post</a>. Do you have ideas why <code>__LINE__</code> does not get expanded?</p>
  
  <p><strong>EDIT</strong>: probably the compiler info is also relevent. I am using visual studio 2010.</p>