title: Determining the type of an expression
body: <p>Sometimes I need to learn the type of an expression while programming in C or C++. Sometimes there's a good IDE or existent documentation to help me, but sometimes not. I often feel such a construct could be useful:</p>
  
  <pre><code>void (*myFunc)(int);
  printf("%s", nameoftype(myFunc)); //"void (*)(int)"
  int i, unsigned int u;
  printf("%s", nameoftype(i+u));    //"unsigned int"
  </code></pre>
  
  <p>This is especially true for C++; think accessors of const objects - do they return a const reference or a copy? Think dynamic casts and templated classes.</p>
  
  <p>How can I do this? (i.e. learn the type of an expression)</p>
  
  <p>I use GCC but as far as I know, it does not have such an extension. So I guess I'm curious as to how people solve this problem. (Both compile-time and runtime solutions welcome.)</p>