c - What type is the reference to an array variable? -
i have following code:
/* * pointer function reads codesegment */ typedef bool (*brcs)(void *, uint32, uint64 *, uint64 *, const char **, const char **); brcs get_prog_id; /* * 'get_prog_id' loaded dynamic library */ uint64 start_o; uint64 length_o; char prog_id[256]; char err[256]; get_prog_id(null, 0, &start_o, &length_o, &prog_id, &err); when run compiler, following warnings:
passing argument 5 of get_prog_id incompatible pointer type passing argument 6 of get_prog_id incompatible pointer type so, it's complaining don't have char ** last 2 arguments.
i'm confused. understanding variable representing array of types equivalent pointer type. such, applying & operator give pointer pointer type.
what missing here?
there 2 problems here:
(1)
the type of &prog_id not char *, it's char (*)[256]; i.e. pointer-to-char-array-of-length-256.
(2)
even if char ** (e.g. char *prog_id = malloc(256); &prog_id), char ** not compatible const char **, obscure reasons. best explanation if here: http://c-faq.com/ansi/constmismatch.html.
Comments
Post a Comment