Given the following function definition:
void f(int const ** ptr_ptr_a);
how would you understand what the function takes and what it guarantees.
- The function takes an
int **
as an argument and guarantees no changes to happen explicitly and only to**ptr_ptr_a
inside the function scope. - The function takes an
int const **
as the function argument, meaning it is imposing that the passed argument needs to be constant before it entered the function scope.
The motivation comes from trying to understand the warning given by the following example:
void f(int const **ptr_ptr_a){
}
int main(int argc, char *argv[])
{
int * ptr_a;
f(& ptr_a); // warning: passing argument 1 of ‘f’ from incompatible pointer type [-Wincompatible-pointer-types]
}
Assuming definition 1. is correct
The warning is useless and makes us think that the inside of the function makes worries about how the variable behaves outside the function scope.
Assuming definition 2. is correct
Means that the declarations arguments and implying what the qualifiers of the arguments passed to the function during calling should have, in which case I'm confused.
I would kindly ask for an explanation on why is this useful given that only pass by value
is possible in C.