Reputation: 3166
alias ("target")
The alias attribute causes the declaration to be emitted as an alias for another symbol, which must be specified. For instance,
void __f () { /* Do something. */; } void f () __attribute__ ((weak, alias ("__f")));
defines
f
to be a weak alias for__f
. In C++, the mangled name for the target must be used. It is an error if__f
is not defined in the same translation unit.Not all target machines support this attribute.
Upvotes: 4
Views: 1321
Reputation: 26800
You can do something like this for C. This is supported for x86 and x64 for msvc v19.15.
#include <stdio.h>
void __f() { puts("This function is aliased"); }
void f();
#pragma comment(linker, "/alternatename:f=__f")
int main()
{
f();
}
See the compiled demo here.
I have tested this in Visual Studio 2017 with /TC
option.
Upvotes: 2