I tested the alias attribute on my own Apple laptop (Target: x86_64-apple-darwin17.5.0). First, I use has_attribute to test that the alias is usable or not. The test code is as follows:
#include <stdio.h>
void print() {
#if has_attribute(alias)
printf("has attribute");
#else
printf("has not attribute");
#endif
}
int main() {
print(); return 0;
}
Compiled using clang, the output result is has attribute, but when i use the following code to verify
#include <stdio.h>
int oldname = 1;
extern int newname attribute((alias("oldname"))); // declaration
void foo(void)
{
printf("newname = %d\n", newname); // prints 1
}
int main() {
foo(); return 0;
}
It told me alias.c:3:35: error: aliases are not supported on darwin.so we should exclude the platform.
How about: If set to false, indicates the attribute is supported only on the given target. If set to true, indicates the attribute is supported on all targets except the given target.