title: define a struct if a certain condition is met
body: <p>I want to <code>typedef</code> a struct in some way if the machine I am on is Little endian and in some other way if it is Big endian.I tried:</p>
  <pre class="lang-c prettyprint-override"><code>unsigned int i = 1; 
     char *c = (char*)&amp;i; 
     if (*c)
     {
         /*Little endian&quot;*/
  
         typedef struct
      {
      
          unsigned long A : A_BIT_SIZE;
          unsigned long R : R_BIT_SIZE;
          unsigned long E : E_BIT_SIZE;
          unsigned long funct : FUNCT_BIT_SIZE;
          unsigned long opsource : OPSOURCE_BIT_SIZE;
          unsigned long sourcetype : SOURCETYPE_BIT_SIZE;
          unsigned long opdest : OPDEST_BIT_SIZE;
          unsigned long desttype : DESTTYPE_BIT_SIZE;
          unsigned long opcode : OPCODE_BIT_SIZE;
  
      }command_byte;
     }   
     else
     {
            /*Big endian&quot;*/
                   typedef struct
      {
          unsigned long opcode : OPCODE_BIT_SIZE;
          unsigned long desttype : DESTTYPE_BIT_SIZE;
          unsigned long opdest : OPDEST_BIT_SIZE;
          unsigned long sourcetype : SOURCETYPE_BIT_SIZE;
          unsigned long opsource : OPSOURCE_BIT_SIZE;
          unsigned long funct : FUNCT_BIT_SIZE;
          unsigned long E : E_BIT_SIZE;
          unsigned long R : R_BIT_SIZE;
          unsigned long A : A_BIT_SIZE;
      
      }command_byte;
  
      }
  </code></pre>
  <p>It compiles, but I am not sure whether this is the valid way to define structs inside an if statement. I am also not sure weather it will work when I actually use the struct. Will at work on header files too? what is the correct way to define a struct if condition is met?</p>