title: How to remove MISRA C errors/warnings on bitwise operations in firmware?
body: <p>I am using MISRA C 2004 standards in <a href="http://en.wikipedia.org/wiki/Code_Composer_Studio" rel="nofollow noreferrer">Code Composer Studio</a>. I am always getting errors with respect to bitwise operations during initialization of the peripherals.</p>
  <p>In the compiler .h file, the definition is like this.</p>
  <pre><code>#define SFR_8BIT(addr)  extern volatile unsigned char addr
  
  SFR_8BIT(REG1);
  
  #define REG2  REG1
  </code></pre>
  <p>Now in my code, if I use</p>
  <pre><code>REG2 |= 0x01;
  </code></pre>
  <p>The MISRA C is popping out these errors:</p>
  <blockquote>
  <ol>
  <li><p>Bitwise operators shall not be applied to operands whose underlying type is signed - #1393-D (MISRA-C:2004 10.1/R)</p>
  </li>
  <li><p>The value of an expression of integer type shall not be implicitly converted to a different underlying type if it is not a conversion to a integer type of the same signedness.</p>
  </li>
  </ol>
  </blockquote>
  <p>I don't want to change the compiler .h file, and I want to eradicate these warnings.</p>