[LLVMdev] function overload in C

David Mirabito david.mirabito at gmail.com
Thu Jun 13 17:04:15 PDT 2013


http://clang.llvm.org/docs/LanguageExtensions.html#function-overloading-in-c

#include <stdio.h>
void __attribute__((overloadable)) onearg(int i) { printf("Arg is int: %d\n", i); }
void __attribute__((overloadable)) onearg(char *s) { printf("Arg is string: %s\n", s); }

int main() {
    onearg(1);
    onearg("String");
    return 0;
}

$ clang test.c && ./a.out
Arg is int: 1
Arg is string: String

On 14/06/2013, at 4:12 AM, Alireza Moshtaghi <Alireza.Moshtaghi at synopsys.com> wrote:

> Hi,
> I’m trying to implement an overloading behavior to some of our builtin functions, and came across the following comment in SemaExpr.cpp
>  
> // Check for overloaded calls. This can happen even in C due to extensions.
> If (Fn->getType() == Context.OverloadTy) { ….
>  
> I was wondering which C extensions is this referring to?
>  
> Thanks
> Ali
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130614/c0784254/attachment.html>


More information about the llvm-dev mailing list