title: How to define macro function with variable name
body: <p>I want to define a macro like </p>
  
  <pre><code>#define AUTO_FUC(x) void x(){}
  </code></pre>
  
  <p>to define a function named x.</p>
  
  <p>I think the function name will be replaced by x passed by arg x.</p>
  
  <pre><code>AUTO_FUC("test")//it should equal to void test(){} I think
  </code></pre>
  
  <p>But it didn't. </p>
  
  <p>So how to do this in C++?</p>
  
  <hr>
  
  <p>I use MinGW and use the macro twice with different args.</p>
  
  <pre><code>AUTO_FUC("A")
  AUTO_FUC("B")
  </code></pre>
  
  <p>It didn't give me function A() and B().Compiler told me <code>void someClass::x() cannot be overloaded</code>.So I know the macro didn't work.</p>
  
  <hr>
  
  <p>Thanks ,I realize the void "A"() is not a correct function. I forgot I pass a macro as arg and the marco is a string.</p>
  
  <p><strong>And further question</strong>. What I really want is create a function with name according to a variable value.And variable value can be write like <code>string a = a;</code>? It should have <code>"</code> am I right? So If I use a string like <code>"A"</code>, how can I use the <code>A</code> to create the function <code>void A()</code> when pass the value to marco? </p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt;
  
  #define AUTO_FUC(x) \
  void x() \
  {\
      std::cout&lt;&lt;"hi";\
  }\
  
  int main()
  {
      std::string A = "A";
      AUTO_FUC(A);  //it's equal to AUTO_FUC("A") it wrong
      A(); //So it's undefined;
  }
  </code></pre>