Why C doesn't allow implicit conversion from char ** to const char *const * (and C++ does)? : <p>I know implicit conversion from <code>char **</code> to <code>const char **</code> cannot be done and why, and that the conversion to <code>char *const *</code> works.  See bottom for links to explanation on that.</p>

<p>It all makes sense apart from one particular thing.  So I have the following code:</p>

<pre><code>#include &lt;stdio.h&gt;

void
print(const char *const*param)
{
    printf("%s\n", param[0]);
}

int
main(int argc, char **argv)
{
    print(argv);
    return 0;
}
</code></pre>

<p>If I compile this as a C++ code, it compiles quite fine.  However, if the same code is compiled as a C code only, I get an error (well, a warning, but let's suppose <code>-Werror</code>, i.e. treat warnings as errors).</p>

<p>gcc:</p>

<pre><code>test.c: In function ‘main’:
test.c:12:11: warning: passing argument 1 of ‘print’ from incompatible pointer type [-Wincompatible-pointer-types]
     print(argv);
           ^
test.c:4:1: note: expected ‘const char * const*’ but argument is of type ‘char **’
 print(const char *const*param)
 ^
</code></pre>

<p>clang:</p>

<pre><code>test.c:12:11: warning: passing 'char **' to parameter of type 'const char *const *' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers]
    print(argv);
          ^~~~
test.c:4:25: note: passing argument to parameter 'param' here
print(const char *const*param)
                        ^
</code></pre>

<p>Both behaviours are standard-independent and also compiler-independent.  I tried various standards with both <code>gcc</code> and <code>clang</code>.</p>

<p>There are two reasons for this inquiry.  Firstly, I want to understand whether there is a difference and, secondly, I have a function that does nothing with any layer of the pointers and I need it to be able to work with <code>const char **</code> as well as <code>char *const *</code> and <code>char **</code>.  Explicitly casting each call is not maintainable.  And I have no idea how should the function prototype look like.</p>

<hr>

<p>This is the question that started my curiosity:
<a href="https://stackoverflow.com/questions/7016098/implicit-conversion-from-char-to-const-char">Implicit conversion from char** to const char**</a></p>

<p>And here is another nice explanation for the <code>char ** =&gt; const char**</code> problem:
<a href="http://c-faq.com/ansi/constmismatch.html">http://c-faq.com/ansi/constmismatch.html</a></p>

<p>If the links are confusing related to this question, feel free to edit them out.</p>
