This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++ constant expressions in __attribute__
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Piotr Wyderski <piotr dot wyderski at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 4 Mar 2009 06:22:54 -0800
- Subject: Re: C++ constant expressions in __attribute__
- References: <9f8a01cd0903040614r4d98d035qf7a74fb65a7616dc@mail.gmail.com>
On Wed, Mar 4, 2009 at 6:14 AM, Piotr Wyderski <piotr.wyderski@gmail.com> wrote:
> Hello,
>
> Is it possible to allow C++ constant expressions (currently static const,
> and C++0x constexpr in the future) to be used as __attribute__ parameters
> in the upcomming version of GCC? In my code I have the following construction:
>
> ? ?namespace simd {
>
> ? ? ? static const std::size_t vector_size = 16U;
> ? ?};
>
> but cannot use it in order to declare a variable like this:
>
> ? std::uint8_t v[128] __attribute__((__aligned__(simd::vector_size)));
>
> because GCC (4.4.0 snapshot from the end of January, x86/Cygwin)
> complains that:
>
> ? ?error: expected ')' before '::' token
>
> rewritten to:
>
> ? ?static const std::size_t len = 16;
> ? ?std::uint8_t v[128] __attribute__((__aligned__(len)));
>
> results in:
>
> ? ?error: requested alignment is not a constant
>
> One needs to introduce a preprocessor macro SIMD_VECTOR_SIZE
> just in order to fix this particular issue.
You can use __BIGGEST_ALIGNMENT__ for that purpose.
--
H.J.