News for hackers. Stuff that matters.
Re:Talking to C Programmers about C++ [video] by faragon on Sunday September 25, 2016 @09:25AM (#12575207)
>>A vector/map of what? How do I have a map of some key to a custom structure? How do you do this simply without templates? Separate libraries? Macro hell?

Separate libraries, without "macro hell".

>>How do you handle types which need to free memory without destructors? Manually loop over the vector and free stuff every time one goes out of scope? That doesn't seem safer to me.

Providing both heap and stack based allocation. E.g. allocating a vector in the stack would require no explicit de-allocation (example: https://github.com/faragon/libsrt). For heap allocation, you would need to call some sometype_free(&a) function, obviously (there is no RAII in C).

Re:Talking to C Programmers about C++ [video] by aksx on Sunday September 25, 2016 @09:46AM (#12575287)
>For heap allocation, you would need to call some sometype_free(&a) function

i find '__attribute__((cleanup (fn)))' fascinating in C, need to try it in some production code though.

Re:Talking to C Programmers about C++ [video] by pjmlp on Sunday September 25, 2016 @10:29AM (#12575464)
That is GCC C, not ANSI C.
Re:Talking to C Programmers about C++ [video] by loeg on Sunday September 25, 2016 @05:31PM (#12577563)
It's quite useful.
Re:Talking to C Programmers about C++ [video] by sseagull on Sunday September 25, 2016 @10:09AM (#12575369)
Yes, but it would still be hard to support custom types, wouldn't it? Ie in your library, I would have to use pointers, which might be unsafe? Adding types to a library like that (like double) causes the amount of code to grow dramatically (maybe even n^2 for maps).

You're library does look nice for what it does, and may have to look into it for some projects (I do have some C projects). Thanks!

Re:Talking to C Programmers about C++ [video] by faragon on Sunday September 25, 2016 @11:16AM (#12575676)
That library is still in beta stage, there are others.

For maps I've implemented integer, pointers, and strings, without code bloat (tree implementation is common, without macro-templates). I'm planning adding some generic type support for fixed-size elements, while keeping internal tree pointer-less and both stack and heap allocation possible, with minimal code bloat/duplication.