title: "Pointer from integer/integer from pointer without a cast" issues
body: <p><em>This question is meant to be a FAQ entry for all initialization/assignment between integer and pointer issues.</em></p>
  
  <hr>
  
  <p>I want to do write code where a pointer is set to a specific memory address, for example <code>0x12345678</code>. But when compiling this code with the gcc compiler, I get "initialization makes pointer from integer without a cast" warnings/errors:</p>
  
  <pre><code>int* p = 0x12345678;
  </code></pre>
  
  <p>Similarly, this code gives "initialization makes integer from pointer without a cast":</p>
  
  <pre><code>int* p = ...;
  int i =  p;
  </code></pre>
  
  <p>If I do the same outside the line of variable declaration, the message is the same but says "assignment" instead of "initialization":</p>
  
  <pre><code>p = 0x12345678; // "assignment makes pointer from integer without a cast"
  i = p;          // "assignment makes integer from pointer without a cast"
  </code></pre>
  
  <p>Tests with other popular compilers also give error/warning messages:</p>
  
  <ul>
  <li>clang says "incompatible integer to pointer conversion"</li>
  <li>icc says "a value of type <code>int</code> cannot be used to initialize an entity of type <code>int*</code>"</li>
  <li>MSVC (cl) says "initializing <code>int*</code> differs in levels of indirection from <code>int</code>".</li>
  </ul>
  
  <p><strong>Question: Are the above examples valid C?</strong> </p>
  
  <hr>
  
  <p>And a follow-up question:</p>
  
  <p>This does not give any warnings/errors:</p>
  
  <pre><code>int* p = 0;
  </code></pre>
  
  <p>Why not?</p>