This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Specify alignment for string literal.
- From: Ian Lance Taylor <iant at google dot com>
- To: Kaz Kylheku <kaz at kylheku dot com>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: Sun, 09 Oct 2011 22:11:29 -0700
- Subject: Re: Specify alignment for string literal.
- References: <4b542aa7f2029423c7e64c5fc6a8f153@127.0.0.1>
Kaz Kylheku <kaz@kylheku.com> writes:
> Is there any way to specify the alignment of a literal, with
> __attribute__
> ((align ...))
Not as such, no.
> That is to say:
>
> /* wchar_t is 16 bits and 2 byte aligned on this
> platform; I want 4 byte alignment */
>
> wchar_t *foo = L"...";
>
> The attribute has to go on the literal object, not on foo, obviously.
Perhaps you could write
static wchar_t foo_str[] __attribute__ ((aligned (4))) = L"...";
wchar_t *foo = foo-str;
Ian