N
nicolas.sitbon
Hi everybody,
This simple C code generates a warning:
#include <stdio.h>
static void func(int const * const * ptr)
{
printf("%d\n", **ptr);
}
int main(void)
{
int i = 13;
int *p_i = &i;
int **p_p_i = &p_i;
func(p_p_i); /* warning : passing argument 1 of ‘func’ from
incompatible pointer type */
func((int const **)p_p_i);
func((int const * const *)p_p_i);
return 0;
}
I have read the international Standard (C99 version), in particular,
6.7.3 (Type qualifiers) and 6.2.7 (Compatible type and composite
type), but I can't find the reason of different behaviours with the 3
function call.
Please can anyone help me to understand this, with, if possible,
reference to the international Standard.
Thanks all.
This simple C code generates a warning:
#include <stdio.h>
static void func(int const * const * ptr)
{
printf("%d\n", **ptr);
}
int main(void)
{
int i = 13;
int *p_i = &i;
int **p_p_i = &p_i;
func(p_p_i); /* warning : passing argument 1 of ‘func’ from
incompatible pointer type */
func((int const **)p_p_i);
func((int const * const *)p_p_i);
return 0;
}
I have read the international Standard (C99 version), in particular,
6.7.3 (Type qualifiers) and 6.2.7 (Compatible type and composite
type), but I can't find the reason of different behaviours with the 3
function call.
Please can anyone help me to understand this, with, if possible,
reference to the international Standard.
Thanks all.