title: How come these programs are allowed to pass a non-const variable and I can't?
body: <p>I've been trying to write a program in C++ with portaudio, trying to make a simple audio application, something that can record and play audio just to learn. So I have a class, and in the class, I initialize a variable <code>PaStreamParameters inputParameters</code>. Alright so later in the code, I open the stream to record like any other program with <code>Pa_OpenStream</code>,</p>
  <pre><code>err = Pa_OpenStream(
          &amp;stream,
          &amp;inputParameters,
          NULL,
          sampleRate,
          framesPerBuffer,
          paNoFlag,
          recordCallback,
          data);
  </code></pre>
  <p>And I get an error that I'm doing an invalid conversion from <code>int (*)(const void*, const void*, long unsigned int, const PaStreamCallbackTimeInfo*, PaStreamCallbackFlags, void*)</code> to an <code>int (*)(const void*, void*, long unsigned int, const PaStreamCallbackTimeInfo*, PaStreamCallbackFlags, void*)</code>; note the second parameter, converting from a <code>const void*</code> to a <code>void*</code>. And it makes sense as I am, in fact passing a non const variable, and <code>Pa_OpenStream</code> was written to have a const input. It is even here in the documentation: <a href="http://www.portaudio.com/docs/v19-doxydocs/portaudio_8h.html#a443ad16338191af364e3be988014cbbe" rel="nofollow noreferrer">http://www.portaudio.com/docs/v19-doxydocs/portaudio_8h.html#a443ad16338191af364e3be988014cbbe</a>. So what's the problem? I've seen in multiple places, <code>Pa_OpenStream</code> being passed a non-const parameters. The recording example code, <a href="http://portaudio.com/docs/v19-doxydocs/paex__record_8c_source.html" rel="nofollow noreferrer">http://portaudio.com/docs/v19-doxydocs/paex__record_8c_source.html</a>, initializes <code>PaStreamParameters  inputParameters, outputParameters;</code>, mutates them, and passes it to <code>Pa_OpenStream</code> just like I did. The Ardour source code, in <code>libs/backends/portaudio/portaudio_io.cc</code>, the <code>open_callback_stream</code> function initializes two <code>PaStreamParameters</code> variables, neither being const, and passes them to <code>Pa_OpenStream</code> (in a modified way, checking if it should pass NULL instead).</p>
  <p>How do these code work and mine don't? None of them pass const input and output parameters to <code>Pa_OpenStream</code> and they work. How do they not get an invalid conversion from <code>const void*</code> to <code>void*</code>?</p>
  <p>audour source code for reference: <a href="https://github.com/Ardour/ardour/blob/master/libs/backends/portaudio/portaudio_io.cc" rel="nofollow noreferrer">https://github.com/Ardour/ardour/blob/master/libs/backends/portaudio/portaudio_io.cc</a></p>