This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: data type & sections
- From: Daniel Lohmann <daniel dot lohmann at informatik dot uni-erlangen dot de>
- To: stefano carucci <stecarucci at hotmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 20 Mar 2007 11:03:29 +0100
- Subject: Re: data type & sections
- References: <BAY131-F35065535280DD0A2DF2022C1700@phx.gbl>
stefano carucci wrote:
>
> Hello all,
>
> my question is:
> Is it possible to set a data type (for example, the type
> "Matrix",customized by means of a struct, or a standard type, as "int")
> in a certain section (defined in the linker script, as ".data") in order
> for every Matrix-items (for example) to be placed in a dedicated memory?
> maybe, by means of a #pragma...?
Gcc supports various attributes to assign linker sections (such as
__attribute__((section, ".mysection")), take a look in the manuals),
which is in general a more flexible mechanism than #pragmas.
Unfortunately, the section attribute can be applied only to
variable/function definitions, not to type definition. Hence, it is not
possible to define a "default section" for all (static) variable
instances of a particular type, even though such feature would be *very*
useful.
If you have full control over the source code you may use a
pre-processor macro as workaround, which instantiates Matrix-items with
the proper attributes.
Daniel