title: #pragma inside #define
body: <p>I'm working in a micro-controller using the <strong>C</strong> language. In this specific micro, the interrupts have to be defined using <code>#pragma</code> in following way:</p>
  
  <pre><code>static void func();
  #pragma INTERRUPT func &lt;interrupt_address&gt; &lt;interrupt_category&gt;
  static void func() { /* function body */ }
  </code></pre>
  
  <p>The <code>&lt;interrupt_address&gt;</code> is address of the interrupt in vector table. The <code>&lt;interrupt_category&gt;</code> is either 1 or 2. For example, to define an interrupt in Port 0 pin 0:</p>
  
  <pre><code>static void _int_p00();
  #pragma INTERRUPT _int_p00 0x10 1
  static void _int_p00() { (*isr_p00)(); }
  </code></pre>
  
  <p>We define actual interrupt service routine elsewhere and use function pointer (like <code>isr_p00</code> in the example) to execute them.</p>
  
  <p>It would be convenient if the interrupts could be defined using a macro. I want do define a macro in following way:</p>
  
  <pre><code>#define DECLARE_INTERRUPT(INT_NAME, INT_CAT) \
      static void _int_##INT_NAME(); \
      #pragma INTERRUPT _int_##INT_NAME INT_NAME##_ADDR INT_CAT \
      static void _int_##INT_NAME() { (*isr_##INT_NAME)(); }
  </code></pre>
  
  <p>The compiler throwing the following error:</p>
  
  <pre><code>Formal parameter missing after '#'
  </code></pre>
  
  <p>indicating following line:</p>
  
  <pre><code>static void _int_##INT_NAME() { (*isr_##INT_NAME)(); }
  </code></pre>
  
  <p>I guess preprocessor directives cannot be used in <code>#define</code>s? Is there any work around?</p>