:: Re: [DNG] Pointer error in the back…
Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Rainer Weikusat
Fecha:  
A: KatolaZ
Cc: dng, aitor_czr
Asunto: Re: [DNG] Pointer error in the backend of Netman
KatolaZ <katolaz@???> writes:
> On Thu, Dec 10, 2015 at 01:11:21PM +0100, aitor_czr wrote:
>> Hi Katolaz,
>>
>> In this case active_wifis is an argument passed by reference. So:
>>
>> active_wifis --> is the address
>> *active_wifis --> is the value
>>
>
> Aitor, sorry for being pedantic on this, but "passing-by-reference"
> exists only in C++, not in C. The only parameter passing in C is by
> value. Then, you can pass an argument that is a pointer to a variable
> instead of a variable, which "mimics" a pass-by-reference, but is
> still a pass-by-value.
>
> Hence, there is no way in C in which "p" and "&p" can be "the same
> thing", especially if you have to decide to use either "p" or "&p" as
> a first parameter of realloc...


There is, but not in a way which would make sense for realloc:

---------
#include <stdio.h>

static int vs[] = {1, 2, 3};

int main(void)
{
    printf("%p\t%p\n", vs, &vs);
    return 0;
}
---------


If we're already "being pedantic" :-)