3 ms·
That’s an annoying workaround at best. It’s not necessary in C. It wouldn’t be necessary in C++ if you could declare incomplete class types but still declare th
by klodolph 8y ago
That’s an annoying workaround at best. It’s not necessary in C. It wouldn’t be necessary in C++ if you could declare incomplete class types but still declare their member functions. This would have zero performance impact and improve encapsulation.
- jcelerier 8y ago> It’s not necessary in C sorry what ? most C libraries I know hide their implementations behind opaque types such as `typedef void* my_handle_t`.
- klodolph 8y agoRight, I'm saying that's not necessary, you can just do this: struct my_type; struct my_type *my_type_new(void); This is more common than `typedef void*` in my experience, because it actually provides some minimal amount of type safety. You can also do this in C++ of course, but you can't use member functions this way. My real complaint here is that the Pimpl idiom in C++ is more cumbersome than a simple forward declaration and free functions, which is available in C.