Liste des Groupes | Revenir à cl c |
On 2024-07-09, bart <bc@freeuk.com> wrote:Arrays can be passed by explicit reference:On 09/07/2024 16:58, Ben Bacarisse wrote:In C, arrays are not passed to functions, period.bart <bc@freeuk.com> writes:>
>Arrays are passed by reference:>
>
void F(int a[20]) {}
>
int main(void) {
int x[20];
F(x);
}
This is the sort of thing that bad tutors say to students so that they
never learn C properly. All parameter passing in C is by value. All of
it. You just have to know (a) what the syntax means and (b) what values
get passed.
The end result is that a parameter declared with value-array syntax is
passed using a reference rather than by value.
>
And it does so because the language says, not because the ABI requires
it. A 2-byte array is also passed by reference.
Therefore ABIs do not say anything about array parameters,That makes a change; most people think that C invented ABIs, which were created in its image.
(or if they do, it's not in relation to C).
Les messages affichés proviennent d'usenet.