title: What is the correct way of casting const char* to char* without changing the API and not getting a warning
body: <p>In my plain C99 project, I have an external C library that defines an interface (via <a href="https://developer.gnome.org/gobject/stable/gtype-non-instantiable-classed.html">GObject interfaces</a>) that I need to implement:</p>
  
  <pre><code>void interface_function (const char *address, [...]);
  </code></pre>
  
  <p>Now, within the implementation (that I need to write) I need to call some other functions from a different library (so I can't change them) to which I need to pass <code>*address</code>, but their method signature omit the <code>const</code> keyword:</p>
  
  <pre><code>void some_api_function (char *address, [...]);
  </code></pre>
  
  <p>Now, if I simply pass <code>*address</code> down to <code>some_api_function</code>, I will get the compiler warning:</p>
  
  <pre><code>warning: passing argument 1 of ‘some_api_function’ discards ‘const’ qualifier from pointer target type [enabled by default]
  </code></pre>
  
  <p>I tried explicitly casting to <code>char *</code> in the function call like this:</p>
  
  <pre><code>`some_api_function ((char*) address, [...]) { ... }
  </code></pre>
  
  <p>but then I just get another warning:</p>
  
  <pre><code>warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
  </code></pre>
  
  <p>The problem is, that this is a larger C project with many people working on and policy is that <code>-Werror</code> is enabled and no code emitting warnings on compile is accepted into the mainline source code.</p>
  
  <p>I can't change the interface definition because it is from a third party, and I can't change the API definitions of the external libraries, either. I know that <code>*address</code> is not modified in the external library (it could be const, but as I said I can't change that)</p>
  
  <p>I also know that to solve this issue, I could just create a copy of the <code>const char*</code> into <code>char *</code>, but that doesn't feel right to me because it involves a unnecessary copy operation .</p>
  
  <p>So what is the elegant or 'right' way to do this?</p>