Skip to content

Request for API to use typed pointers instead of intptr_t #96

Description

@jengelh

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:

#include <libpff.h>
void f(libpff_record_set_t *x) {}
int main()
{
        libpff_item_t *x = NULL;
        f(x);
}

Observed:

» gcc x.c -Wall
»

Expected to see:

» 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 *’

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions