4 ms·
i think you mean void pointers. the callee will then cast those pointers to an actual type it knows about (and then possibly go horribly wrong)
by zabzonk 2y ago
i think you mean void pointers. the callee will then cast those pointers to an actual type it knows about (and then possibly go horribly wrong)
- tialaramex 2y agoNo, I don't mean void pointers, I'm talking about just pointers to some unknown type T. What's inside a T? How can we make one? We don't know, but that's fine since we have been provided with APIs which give us a pointer-to-T and which take a pointer-to-T so it delivers the opacity required.
- dpassens 2y agoNo, you can just use a pointer to struct S without ever defining the fields of S, no void pointers required.
- acuozzo 2y agoIf the definition is known at some point during compilation. What if you're providing an API header to an otherwise closed-source binary and you don't want to expose the struct definition? How would the compiler know the size and alignment required for struct Foo if it never gets to see its definition?
- gpderetta 2y agoIncomplete types. Void is just a special kind of incomplete type.