Repository navigation
Conversation
|
These were the errors after just changing the typedefs brought up the errors: |
| typedef intptr_t libpff_name_to_id_map_entry_t; | ||
| typedef intptr_t libpff_record_entry_t; | ||
| typedef intptr_t libpff_record_set_t; | ||
| typedef struct libpff_internal_file libpff_file_t; |
There was a problem hiding this comment.
This is not portable unfortunately, internal structs should remain internal to the library. This way they leak into the public API
There was a problem hiding this comment.
Their insides do not leak.
$ cat 1.c
#include <libpff.h>
int main()
{
libpff_file_t *a = NULL;
libpff_error_t *err = NULL;
libpff_file_initialize(&a, &err);
a->io_handle;
}
$ gcc 1.c -Wall
1.c: In function ‘main’:
1.c:7:10: error: invalid use of incomplete typedef ‘libpff_file_t’ {aka ‘struct libpff_internal_file’}
7 | a->io_handle;
| ^~
or did you mean something different?
There was a problem hiding this comment.
AFAIR we discussed this already on #96 (comment) "public structs as proxy pointers, these are not supported by every compiler"
There was a problem hiding this comment.
I must have missed that in 2026.
Then again, also in 2026, which compiler is it that does not support this? At least so I can test...
There was a problem hiding this comment.
I'll need to dig it up when time permits, for now the code should stick with the intptr_t proxy pointers.
There was a problem hiding this comment.
"No ANSI/ISO-compliant C compiler fails to support a typedef to a forward-declared (incomplete) struct (e.g., typedef struct foo foo_t;). That pattern—an opaque type—is explicitly guaranteed by every C standard since C89. https://stackoverflow.com/questions/3965279/opaque-c-structs-various-ways-to-declare-them" (googlai summary)
There was a problem hiding this comment.
Note that you can argue all you want it will not change my current stance.
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## main #175 +/- ##
==========================================
- Coverage 28.90% 23.34% -5.57%
==========================================
Files 64 63 -1
Lines 21062 20948 -114
Branches 5075 5064 -11
==========================================
- Hits 6088 4890 -1198
- Misses 13022 14923 +1901
+ Partials 1952 1135 -817 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Since the "definition" for libpff_file_t is freely changable, I made it a struct {void*} as originally set out in #96 (comment) |
|
I just found this in libolecf, which seems to be doing something quite similar, save for being behind an ifdef. |
Doing this change from
intptr_ttotypedef struct…immediately brings up actual coding errors where wrong parameters are passed.References: #96