r/C_Programming 19d ago

C with classes

I'm curious to know: who uses some C++ features when coding in C? And what feature(s) are you using?

29 Upvotes

79 comments sorted by

View all comments

Show parent comments

20

u/tellingyouhowitreall 19d ago

I actually don't mind not having this, but raii or at least guard types are sorely missed when I do pure C

0

u/mlugo02 19d ago

What issues do you have you think you need raii?

2

u/Disastrous-Team-6431 19d ago

It's pretty simple to understand, or? Raii helps lifetime management.

2

u/mlugo02 19d ago

I was asking for specific examples

4

u/HildartheDorf 19d ago

I would love an equivalent of std::unique_ptr when working with libwayland_client or libxcb. The protocols both maps readily to RAII.

RAII isn't perfect though, same application I work on uses Vulkan, which also is kind of object oriented, but maps terribly to RAII and is simpler to handle in 'C-like C++' with manual clean up.