重载 C 函数

在 clang 的扩展下,可以重载 C 函数,例如重载 sin 函数:

float __attribute__((overloadable)) sin(float x) { return sinf(x); }
double __attribute__((overloadable)) sin(double x) { return sin(x); }
long double __attribute__((overloadable)) sin(long double x) { return sinl(x); }

相关文档:Clang Language Extensions

posted @ 2013-06-20 12:10  Proteas  阅读(333)  评论(0编辑  收藏  举报