title: How to use noreturn with function pointer?
body: <p>I am writing a bootloader in C11. When the bootloader needs to transfer the control to the firmware, it reads a function pointer at a predefined memory address and calls it. The code looks like this:</p>
  
  
  
  <pre class="lang-c prettyprint-override"><code>typedef void (FirmwareBootFn)(void);
  
  typedef struct
  {
      uint32_t stackPointer;
      FirmwareBootFn* programCounter;
  }
  FirmwareBootControl;
  
  static FirmwareBootControl g_bootControl __attribute__ ((section (".boot_control")));
  
  void
  Firmware_boot( void )
  {
      setStackPointer( g_bootControl.stackPointer );
      g_bootControl.programCounter();
  }
  </code></pre>
  
  <p>Function <code>Firmware_boot()</code> never returns, so it made sense to declare it as <code>noreturn</code>:</p>
  
  <pre class="lang-c prettyprint-override"><code>#include &lt;stdnoreturn.h&gt;
  
  noreturn void
  Firmware_boot( void );
  </code></pre>
  
  <p>But I need to declare <code>FirmwareBootFn</code> as <code>noreturn</code> as well to avoid the compiler complaining that <code>Firmware_boot()</code> may return.</p>
  
  <p>I tried (possibly) every permutation of the <code>noreturn</code> in the <code>typedef</code> without any result. Also I understood that the attribute can't be set in the <code>typedef</code> because it is not part of the type.</p>
  
  <p>Is there a way to tag my <code>Firmware_boot()</code> as <code>noreturn</code> avoiding the warning (well without cheating with warning suppression :-))?</p>