You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The definition of libpff_item_t is compatible to libpff_record_set_t (and possibly others). This is very unfortunate, because it masks developer errors, for example when a logically different-typed thing is passed:
» gcc x.c -Wall
x.c: In function ‘main’:
x.c:11:4: warning: passing argument 1 of ‘f’ from incompatible pointer type [-Wincompatible-pointer-types]
11 | f(x);
x.c:7:29: note: expected ‘libpff_record_set_t *’ but argument is of type ‘libpff_item_t *’
The text was updated successfully, but these errors were encountered:
Off the top of my head, two options. A forward declaration of an incomplete struct is common:
struct libpff_file;
extern int file_get_item(struct libpff_file *x, int itmidx);
Alternatively, one could wrap intptr into a struct. Since both have the same size, passing the entire struct as an argument shouldn't incur any extra cost.
struct libpff_file {
uintptr_t realptr; // at this point one could also just use void *.
};
extern int file_get_item(struct libpff_file x, int itmidx);
The definition of
libpff_item_t
is compatible tolibpff_record_set_t
(and possibly others). This is very unfortunate, because it masks developer errors, for example when a logically different-typed thing is passed:Observed:
Expected to see:
The text was updated successfully, but these errors were encountered: