title: Proper way for declaring binary rotation preprocessor macro
body: <p>I would like to create macros for binary rotations. 
  My goal was to make those macros universal for both <code>uint32_t</code> and <code>uint64_t</code> operand types.</p>
  
  <p>I came to this implementation:
  </p>
  
  <pre><code>#define ROTL(X, N)  (((X) &lt;&lt; (N)) | ((X) &gt;&gt; (8 * sizeof(X) - (N))))
  #define ROTR(X, N)  (((X) &gt;&gt; (N)) | ((X) &lt;&lt; (8 * sizeof(X) - (N))))
  </code></pre>
  
  <p>Those macros work fine but <code>gcc</code> compiler produces warnings during compilation:</p>
  
  <pre class="lang-none prettyprint-override"><code>warning: right shift count &gt;= width of type [enabled by default]
  #define ROTL(X, N)  (((X) &lt;&lt; (N)) | ((X) &gt;&gt; (8 * sizeof(X) - (N))))
  
  warning: left shift count &gt;= width of type [enabled by default]
  #define ROTL(X, N)  (((X) &lt;&lt; (N)) | ((X) &gt;&gt; (8 * sizeof(X) - (N))))
  </code></pre>
  
  <p>I know that compiler is complaining about possible mismatch between type of <code>X</code> and <code>N</code>. But warnings are produced even when I cast both <code>X</code> and <code>N</code>:</p>
  
  <pre class="lang-c prettyprint-override"><code>ROTL((uint32_t)0xdeadbeef, (uint32_t)0U);
  </code></pre>
  
  <p>What can I do to get rid of these warning the proper way?</p>