this post was submitted on 18 Jul 2023
25 points (100.0% liked)

Programming

13383 readers
1 users here now

All things programming and coding related. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 2 years ago
MODERATORS
 

C is an old language lacking many, many, many modern features. One of the features it does not lack is encapsulation and isolation.

you are viewing a single comment's thread
view the rest of the comments
[–] Kajo 3 points 1 year ago

Thank you for the article. Opaque struct is an interesting subject for people who want to go deeper into their understanding of C.

If I could add/emphasis two points to the article:

  • FILE is a famous example of struct using this trick. So, even if yon don't often need to develop an opaque struct in C, you certainly use such struct daily without knowing.

  • you can't declare a variable with an opaque type (because the compiler would need to know its size). Everything must be handled through pointers, and the library has to provide functions to allocate/destroy the struct, like fopen() and fclose() for FILE.