[chbot] GCC / Codesourcery #pragma for ARM Cortex M3
Volker Kuhlmann
list0570 at paradise.net.nz
Sat Oct 29 04:40:49 BST 2011
On Wed 26 Oct 2011 10:44:48 NZDT +1300, Charles Manning wrote:
> Unless you really, really need to don't use pragmas. They make code
> non-portable.
Yes and no. Their purpose is to control the compiler past the limits of
the standard, and non-understood pragmas are required to be ignored
without error. The position of needing one arises frequently in embedded
programming because there aren't enough keywords in the standard, e.g.
for storage class. gcc's __attribute__() is much the same purpose and
actually worse because other compilers will rightly throw an error. The
advantage is that it can be ifdef'ed away for non-gcc.
Yes you want to avoid them but most of what __attribute__() does can not
be achieved any other way and it's absolutely necessary.
In this case putting the function requiring special compiler options in
its own module is the right way to go, but I can also see this being
potentially problematic or impossible if there are dependencies on other
things in the same module, e.g. for optimisations.
Volker
--
Volker Kuhlmann
http://volker.dnsalias.net/ Please do not CC list postings to me.
More information about the Chchrobotics
mailing list