title: PSTR() on __FUNCTION__
body: <p>Using <code>avr-gcc</code> it is possible to store data on Program Memory in order to save RAM. This is acomplished using <a href="http://www.nongnu.org/avr-libc/user-manual/pgmspace.html" rel="nofollow noreferrer">PROGMEM attribute</a>. AVR-libc also provides a macro, <a href="http://www.nongnu.org/avr-libc/user-manual/FAQ.html" rel="nofollow noreferrer">PSTR()</a>, which can be used to with literal strings.</p>
  
  <p>Now I'm trying to use <code>PSTR()</code> with <a href="https://stackoverflow.com/questions/4384765/whats-the-difference-between-pretty-function-function-func"><code>__func__</code>, <code>__FUNCTION__</code> or <code>__PRETTY_FUNCTION__</code>.</a></p>
  
  <p>The following code works as expected,</p>
  
  <pre><code>display.message(__func__, 2);
  display.message(__FUNCTION__, 2);
  display.message(__PRETTY_FUNCTION__, 2);
  </code></pre>
  
  <p>, while the compilation of any of these lines fails,</p>
  
  <pre><code>display.messageP(PSTR(__func__), 2);
  display.messageP(PSTR(__FUNCTION__), 2);
  display.messageP(PSTR(__PRETTY_FUNCTION__), 2);
  </code></pre>
  
  <p>, with the following error:</p>
  
  <pre><code>initializer fails to determine size of '__c'
  </code></pre>
  
  <p>The definition of PSTR, from WinAVR/avr/include/avr, explains the variable referenced on the error message:</p>
  
  <pre><code># define PSTR(s) (__extension__({static char __c[] PROGMEM = (s); &amp;__c[0];}))
  </code></pre>
  
  <p>This is not something general to macros, as <code>__FILE__</code> compile and work fine:</p>
  
  <pre><code>display.messageP(PSTR(__FILE__), 2);
  </code></pre>
  
  <p>Any ideas on what is causing this error, and if it possible to use PSTR() to insert function name on program memory?</p>