title: Using _Generic for printf formatting
body: <p>I find myself often entering in the wrong formatting type, and not remembering when to do <code>f</code> or <code>Lf</code> or <code>lf</code>, etc. Is there a way to do something like the following with the help of the <code>_Generic</code> keyword?</p>
  <pre><code>#define TYPE(X)   _Generic((X), float: &quot;float&quot;, double: &quot;double&quot;, long double: &quot;long_double&quot;)
  #define FORMAT(X) _Generic((X), float: &quot;%f&quot;,    double: &quot;%f&quot;,     long double: &quot;%Lf&quot;)
  
  printf(&quot;%s if of type %s\n&quot;, FORMAT(10.), 10., TYPE(10.));
  </code></pre>
  <p>Basically, I want it to print:</p>
  <blockquote>
  <p>10.000000 is of type double</p>
  </blockquote>
  <p>Is there a way to do that?</p>
  <p>I suppose one shorthand option would be doing something like:</p>
  <pre><code>#define TYPE(X)     _Generic((X), float: &quot;float&quot;, double: &quot;double&quot;, long double: &quot;long_double&quot;)
  #define STRINGIZE(X)   #X
  printf(&quot;%s if of type %s\n&quot;, STRINGIZE(10.), TYPE(10.));
  </code></pre>
  <blockquote>
  <ol start="10">
  <li>if of type double</li>
  </ol>
  </blockquote>