public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Output section of string literal in initializer
@ 2007-03-22 16:38 Udo A. Steinberg
  0 siblings, 0 replies; only message in thread
From: Udo A. Steinberg @ 2007-03-22 16:38 UTC (permalink / raw)
  To: gcc-help

Hello,

In the example below I would like the string literals "foo", "bar" and "baz" to
reside in .mysection. This works when using a pointer variable ptr as shown for
"baz".

Is there any way to specify the output section of string literals in an
initializer (e.g., "foo" and "bar") without using using a pointer variable?
I'm looking for something like { "foo" MYSECTION, 1 }.

#define MYSECTION __attribute__((section (".mysection")))
char const *const ptr MYSECTION = "baz";
struct
{
    char const *string;
    unsigned number;
} x[] MYSECTION =
{
    { "foo",     1 },
    { "bar",     2 },
    {  ptr,      3 },
};



Cheers,

	- Udo

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-03-22 16:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-22 16:38 Output section of string literal in initializer Udo A. Steinberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).