[cfe-dev] RFC: Function Overloading in C

Sebastian Redl sebastian.redl at getdesigned.at
Fri Feb 13 02:01:45 PST 2009


Douglas Gregor wrote:
> Hi all,
>
> I've just finished the implementation of the "overloadable" function  
> attribute that introduces function overloading into C. The intent is  
> to make it easier to implement "type-generic" functions (such as those  
> in tgmath.h and altivec.h). The feature is in Clang's trunk, and is  
> documented here:
>
> 	http://clang.llvm.org/docs/LanguageExtensions.html#overloading-in-c
>
> Comments welcome!
>   
I wonder if it's possible (and a good idea) to use the C++ linkage
specification syntax for this, i.e.

extern "C++" double tgsin(double d) { return sin(d); }
extern "C++" float tgsin(float f) { return sinf(f); }
extern "C++" long double tgsin(long double d) { return sinl(d); }

As a C++ programmer, it looks more natural to me. Of course, I have no
idea how this would look to a pure C programmer. Also, this syntax would
imply that we will always mangle this like C++ names.

Sebastian



More information about the cfe-dev mailing list