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]

Output section of string literal in initializer


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


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