How can I generate a compile-time array of interrupt handlers in C++?
<p>I'd like to be able to write my ISR in one place:</p>

<pre><code>some_collection TimerHandlers;    

// added to ISR table in linker script
void rawTimerIRQHandler() {
    call_each_handler_in(handlers);
}
</code></pre>

<p>Such that I can then register handlers in other files</p>

<pre><code>// file1.cpp
void ledTimerHandler1() {

}
register(ledTimerHandler1); //or in an init function if not possible here
</code></pre>



<pre><code>// file2.cpp
void ledTimerHandler2() {

}
register(ledTimerHandler2); //or in an init function if not possible here
</code></pre>

<p>And when the hardware jumps to <code>rawTimerIRQHandler</code>, it executes <code>ledTimerHandler1</code> and <code>ledTimerHandler2</code> in some arbitrary order.</p>

<hr>

<p>Obviously, I can implement this using something similar to a <code>vector&lt;void(*)()&gt;</code>, but since the number of these handlers is known at compile-time, is there any way I can generate an array (or template linked list) at compile-time? I'd like to avoid the dynamic memory allocation that comes with <code>vector</code>.</p>

<p>I'm open to using <code>template&lt;&gt;</code>, <code>#define</code>, or even GCC-specific attributes to acheive this goal.</p>
