FAQ: Data Member Alignment - How can I use the variable alignment attribute?

Document created by Kader.M Employee on Dec 4, 2017
Version 1Show Document
  • View in full screen mode



I have a C++ header file with class declaration.  Part of the declaration is a data member.

 int a;

I need to ensure correct alignment.  According to documentation I should be able to do the following.

int a __attribute__ ((aligned (8)));

However, I get an error.

".\foo.h", line 92: cc0065: error: expected a ";"
                int a __attribute__ ((aligned (8)));

I am using CCES 2.1.0.

How can I use the variable alignment attribute?





The GCC compatibility extensions are only available in C89 and C99 modes.They are not accepted in C++ dialect mode, unless enabled with the -g++ switch".
So please add '-g++' switch in to compiler > additional options in your C++ project before the build.


Please refer the CCES help path for more details.
CrossCore® Embedded Studio 2.5.0 > SHARC® Development Tools Documentation > C/C++ Compiler Manual for SHARC® Processors > Compiler > C/C++ Compiler Language Extension