This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: __attribute__((alias())) for variables?
- From: Ian Lance Taylor <iant at google dot com>
- To: Rabih Chrabieh <chrabieh at yahoo dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 06 May 2009 06:58:34 -0700
- Subject: Re: __attribute__((alias())) for variables?
- References: <4A009F3E.6080601@yahoo.com> <m3d4amhj21.fsf@google.com> <4A013D94.1020808@yahoo.com>
Rabih Chrabieh <chrabieh@yahoo.com> writes:
> I will add the following question: for variables, it doesn't seem like there is
> a mechanism to create an "alias" that is "local" to a file.
>
> It seems like we must use "extern" (otherwise the compiler reports that the
> variable is "defined both normally and as an alias").
> And if we use extern, we cannot combine it with "static" (the compiler reports
> "multiple storage classes").
>
> Hence, contrary to functions, it looks like an aliased variable is always
> global (the assembler is always using .global). This is partly an issue of the
> C language that extern and static cannot be combined for variables, but extern
> can be omitted for functions. Unless there is a trick that you know of?
>
> In summary, these constructs work properly for functions but not for variables:
>
> static void f() {return;}
> static void g() __attribute__((alias("f")));
>
> static int AAA;
> extern static int BBB __attribute__((alias("AAA")));
I'm actually surprised that that works for functions.
I would encourage you to file a bug report about this. See
http://gcc.gnu.org/bugs.html . Thanks.
Ian