blob: 8a1fac9d9c432ff3eea7d12b8aa6582997bdbd74 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
|
<div class="section-level-extent" id="Pointers-to-Arrays"> <div class="nav-panel"> <p> Next: <a href="initializers" accesskey="n" rel="next">Non-Constant Initializers</a>, Previous: <a href="variadic-pointer-args" accesskey="p" rel="prev">Pointer Arguments in Variadic Functions</a>, Up: <a href="c-extensions" accesskey="u" rel="up">Extensions to the C Language Family</a> [<a href="index#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="indices" title="Index" rel="index">Index</a>]</p> </div> <h1 class="section" id="Pointers-to-Arrays-with-Qualifiers-Work-as-Expected"><span>6.26 Pointers to Arrays with Qualifiers Work as Expected<a class="copiable-link" href="#Pointers-to-Arrays-with-Qualifiers-Work-as-Expected"> ¶</a></span></h1> <p>In GNU C, pointers to arrays with qualifiers work similar to pointers to other qualified types. For example, a value of type <code class="code">int (*)[5]</code> can be used to initialize a variable of type <code class="code">const int (*)[5]</code>. These types are incompatible in ISO C because the <code class="code">const</code> qualifier is formally attached to the element type of the array and not the array itself. </p> <div class="example smallexample"> <pre class="example-preformatted" data-language="cpp">extern void
transpose (int N, int M, double out[M][N], const double in[N][M]);
double x[3][2];
double y[2][3];
<span class="r">…</span>
transpose(3, 2, y, x);</pre>
</div> </div><div class="_attribution">
<p class="_attribution-p">
© Free Software Foundation<br>Licensed under the GNU Free Documentation License, Version 1.3.<br>
<a href="https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Pointers-to-Arrays.html" class="_attribution-link">https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Pointers-to-Arrays.html</a>
</p>
</div>
|