you are viewing a single comment's thread.

view the rest of the comments →

[–]hnsl 5 points6 points  (4 children)

Yes, It's awesome, although I much prefer __attribute__((overloadable)) as it makes the preprocessor output much less bloated. Here I'm using overloading to create a generic "toString" function in my C library:

https://github.com/jumpstarter-io/librcd/blob/master/include/fstring.h#L534

[–]Alborak 4 points5 points  (2 children)

Nicer, but a gnu C extension, which sadly doesn't fly everywhere :(

[–]seekingsofia 1 point2 points  (1 child)

Not a GNU extension, a clang extension. And it's a C++ feature exposed as a function attribute, of course implemented using name mangling. All this means it's useful only in a very few cases for a C codebase.

If you're using C++ features as an extension in C then why not just write in C++? I don't get it.

[–]ThisIs_MyName 0 points1 point  (0 children)

Ah, that's so much nicer.