title: How to printf a 64-bit integer as hex?
body: <p>With the following code I am trying to output the value of a <code>unit64_t</code> variable using <code>printf()</code>. Compiling the code with gcc, returns the following warning:</p>
  
  <blockquote>
    <p>warning: format ‘%x’ expects argument of type ‘unsigned int’,
    but argument 2 has type ‘uint64_t’ [-Wformat=]</p>
  </blockquote>
  
  <p>The code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdint.h&gt;
  
  int main ()
  {
      uint64_t val = 0x1234567890abcdef;
      printf("val = 0x%x\n", val);
  
      return 0;
  }
  </code></pre>
  
  <p>The output:</p>
  
  <pre><code>val = 0x90abcdef
  </code></pre>
  
  <p>Expected output:</p>
  
  <pre><code>val = 0x1234567890abcdef
  </code></pre>
  
  <p>How can I output a 64bit value as a hexadecimal integer using <code>printf()</code>? The <code>x</code> specifier seems to be wrong in this case.</p>