title: Macro errors with member function
body: <p>I'm having fun with macros (not)</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  #define DEF_ATTRIBUTE(type, name) type name;\
      typedef void (*type_name_t)(CLASS_NAME*);\
      type_name_t ptr_type_name;\
      void type_name(){( ptr_type_name = &amp;CLASS_NAME::type_name);}\
  
  class Test
  {
      public:
          #define CLASS_NAME Test
          DEF_ATTRIBUTE(int, i_Test);
  
          void Print()
          {
              cout &lt;&lt; "Test::Print()" &lt;&lt; endl;
          }
  };
  
  int main()
  {
      Test t;
      t.Print();
  }
  </code></pre>
  
  <p>Which expands to :</p>
  
  <pre><code>class Test
  {
      public:
  
          int i_Test; typedef void (*type_name_t)(Test*); type_name_t ptr_type_name; void type_name(){( ptr_type_name = &amp;Test::type_name);};
  
          void Print()
          {
              cout &lt;&lt; "Test::Print()" &lt;&lt; endl;
          }
  };
  </code></pre>
  
  <p>And yields the compiler error :</p>
  
  <blockquote>
    <p>main.cpp: In member function void Test::type_name():<br>
        main.cpp:16: error: cannot convert void (Test::<em>)() to void (</em>)(Test*) in assignment</p>
  </blockquote>
  
  <p>As far as I can understand, the function pointers are equivalent. What am I doing wrong?</p>