Skip to content

clang claims weak aliases are not supported on Darwin but only when using __attribute__, works fine with #pragma #71001

@CodingMarkus

Description

@CodingMarkus

clang claims weak aliases are not supported on Darwin. The following code doesn't compile:

#include <stdio.h>

int func1( ) { return 42; }
__attribute__((weak, alias("func1")))  int func2( );

int main( )
{
	printf("%d\n", func2());
	return 0;
}

Output:

test1.c:4:22: error: aliases are not supported on darwin
__attribute__((weak, alias("func1")))  int func2( );
                     ^
1 error generated.

But that's not true. Weak aliases are supported on Darwin. The following code will compile and will behave correctly:

#include <stdio.h>

int func1( ) { return 42; }

#pragma weak func2 = func1
int func2( );

int main( )
{
	printf("%d\n", func2());
	return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"platform:macos

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions