title: C sizeof equivalent for macros
body: <p>So I'm optimizing some code by unrolling some loops (yes, I know that I should rely on my compiler to do this for me, but I'm not working with my choice of compilers) and I wanted to do so somewhat gracefully so that, in case my data size changes due to some edits in the future, the code will degrade elegantly.</p>
  
  <p>Something like:</p>
  
  <pre><code>typedef struct {
      uint32_t alpha;
      uint32_t two;
      uint32_t iii;
  } Entry;
  
  /*...*/
  
  uint8_t * bytes = (uint8_t *) entry;
  #define PROCESS_ENTRY(i) bytes[i] ^= 1; /*...etc, etc, */ 
  #if (sizeof(Entry) == 12)
      PROCESS_ENTRY( 0);PROCESS_ENTRY( 1);PROCESS_ENTRY( 2);
      PROCESS_ENTRY( 3);PROCESS_ENTRY( 4);PROCESS_ENTRY( 5);
      PROCESS_ENTRY( 6);PROCESS_ENTRY( 7);PROCESS_ENTRY( 8);
      PROCESS_ENTRY( 9);PROCESS_ENTRY(10);PROCESS_ENTRY(11);
  #else
  #   warning Using non-optimized code
      size_t i;
      for (i = 0; i &lt; sizeof(Entry); i++)
      {
          PROCESS_ENTRY(i);
      }
  #endif
  #undef PROCESS_ENTRY
  </code></pre>
  
  <p>This not working, of course, since <code>sizeof</code> isn't available to the pre-processor (at least, that's what <a href="https://stackoverflow.com/questions/373252/c-sizeof-with-a-type-or-variable/380278#380278">this answer</a> seemed to indicate).</p>
  
  <p>Is there an easy workaround I can use to get the <code>sizeof</code> a data structure for use with a C macro, or am I just SOL?</p>