[cfe-dev] Pointers to Overloaded C Functions
gwk.lists at gmail.com
Mon Jan 11 21:59:29 PST 2010
>>> I am experimenting with clang's overloaded C functions, and I can't figure out how to get a pointer to an overloaded function.
>> Umm, interesting... I think it's just some missing logic in the code for assignments in C. I don't think anyone considered that someone might write code like that.
> I don't know if we even want to support that kind of code... the "overloadable" attribute is narrowly defined to help support certain weird C99-isms (*cough* tgmath.h *cough*). We don't really want to encourage widespread use, since it is likely to never be portable.
Thanks for your replies, and sorry for taking so long to respond. If it is valid to take the address of an overloaded function in C++, then it seems reasonable to expect that one could do so with the overload feature in C too. I understand that this is not a portable feature, but that is no reason not fully implement it (in the sense of completeness relative to C++). I certainly don't expect this to be a priority for anyone; nevertheless, it seems weird to me that you could write functions but not be able to get their addresses due to syntactic limitations.
This is, at the moment, an academic inquiry on my part, but for the record I do think that overloaded functions are a great extension, and people like me (mac developers) do have the luxury of writing single platform code. My primary interest in overloads is that they can simplify generated C code, which I use as a simpler alternative to C++ templates.
More information about the cfe-dev