title: Assignment of const to non-const in C
body: <p>In the following:</p>
  
  <pre><code>struct adt { void * A; };
  
  int new_adt(const void * const A)
  {
      struct adt * r = malloc(sizeof(struct adt));
      r-&gt;A = A;
  }
  </code></pre>
  
  <p>I get:</p>
  
  <blockquote>
    <p>warning: assignment discards qualifiers from pointer target type</p>
  </blockquote>
  
  <hr>
  
  <p>I know I can use</p>
  
  <pre><code>memcpy(&amp;(r-&gt;A), &amp;A, sizeof(void *));
  </code></pre>
  
  <p>to workaround it, but I must ask: Is there any alternative?</p>
  
  <p>By using <code>const void * const</code> I pretend to say that no changes will be made to the input. Also, now that I think of it, <code>const void *</code> would suffice, wouldn't it? (Since I can't change the pointer so that it affects the caller)</p>
  
  <p>Thanks for taking the time to read.</p>