This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Pragmas in GCC


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]