Hello. I have a doubt about argument conversion when passing arguments
to a function. I have a function like:
struct packet *pkt_interest(const char **usrs);
struct packet is defined elsewhere (it has no interest to show it here).
With that "const" modifier I want to state that usrs pointer will not
be changed inside the function.
Then, from the main program, I have this:
char *users[] = {
"alberto",
"juan",
"pepito",
NULL
};
struct packet *pkt = pkt_interest(users);
compiler throws the warning:
test_proto.c:23: warning: passing arg 1 of `pkt_interest' from
incompatible pointer type.
And I have to modify the users declaration to be "const char *users" or
make an explicit cast in the function call.
I though the const modifier in the funcion declaration was just a "hey,
i won't change your pointer, trust me" and could use a plain char **, in
a similar way as we use strcpy function (the second argument is a const
char *, but we can use a non-const char * with no problems).
¿Where's the difference with the const in strcpy and the const in my
pkt_interest?
TIA
--
Luis Alberto Giménez
JabberID: Si*******@bulmalug.net
GnuPG ID: 0x3BAABDE1