title: Const-correctness in C pointer-to-pointer parameters
body: <p>I am currently working on a project to get into more advanced concepts of C. One of the concepts I want to learn about is const-correctness, so I decided to make my entire codebase abide by this idea.</p>
  <p>Say we have a function like this:</p>
  <pre class="lang-cpp prettyprint-override"><code>/*
   * Creates and displays a window.
   * 
   * Returns non-zero on failure, 0 on success.
   */
  extern int window_create(
      _In_z_   char const *const pz_title, /* window title */
               uint32_t width,             /* width in pixels */
               uint32_t height,            /* height in pixels */
               bool isvsync,               /* Should VSync be enabled? */
      /*
       * Pointer to a pointer to a &quot;window&quot; structure
       * that will receive the freshly-created window. 
       * Must not be NULL.
       */
      _Outptr_ struct window **pps_window
  );
  </code></pre>
  <p>A window will be created, and the pointer pointed to by <code>pps_window</code> will then point to the newly-created window struct.</p>
  <p>Now, should I enforce const-correctness on the <code>window **</code> parameter as well? Like so:</p>
  <pre class="lang-cpp prettyprint-override"><code>struct window **const pps_window
  </code></pre>
  <p>The thing is, in my opinion, because the pointer to the pointer itself is passed-by-value anyway, wouldn't explicitly marking it as const be somewhat pointless because the caller does not have to care if the pointer-to-pointer copy on the stack gets modified, or would it  still be good practice to add it nonetheless?</p>