Re:I write type-safe generic data structures in C
by vbezhenar on Monday June 30, 2025 @06:35PM
(#44428660)
C++ code compiles to a different function names in object file (name mangling). You probably need to put a lot of ugly `#ifdef __cplusplus extern "C" {` boilerplate in your headers, otherwise C and C++ files will not compile together.
[ Parent
| on HN ]
Re:I write type-safe generic data structures in C
by winocm on Monday June 30, 2025 @07:01PM
(#44428835)
Don't forget the infamous pattern used in some C projects too:
struct foo decl = {
.member = /* ... */
.next = &(struct nested_pointer) {
.nested_member = /* ... */,
},
.array = (struct nested_array[]) {
[0] = { /* ... */ },
}
};
This pattern does not work in C++ as the nested declarations become temporaries.