This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Pragmas in GCC
- From: Brian Dessent <brian at dessent dot net>
- To: ZeMan <marckhayat at yahoo dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Thu, 31 May 2007 23:29:08 -0700
- Subject: Re: Pragmas in GCC
- References: <10907196.post@talk.nabble.com>
- Reply-to: gcc-help at gcc dot gnu dot org
ZeMan wrote:
> I would like to investigate the use of pragmas in GCC. What are
> pragmas, how are
> they used, what are their limitations, and how can they be used to
> carry information from
> the source code to various optimizing passes. Specifically, I would
> like to investigate how pragmas can be used to allocate variables to
> specific memory banks.
>
> Can anybody give me a summary, or a link to a document where I can
> find such details?
gcc does not use #pragma for much of anything, if at all. To specify
what section a function or variable should be placed in, you use
__attribute__((section("foo"))), and the linker script maps sections to
ram/rom/flash/whatever. Likewise for optimizer hints, they are all done
with __attribute__, e.g. noreturn, used, unused, hot, cold, ...
This is all documented in the gcc manual:
http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html
http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html
Brian