This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Output section of string literal in initializer
- From: "Udo A. Steinberg" <us15 at os dot inf dot tu-dresden dot de>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 22 Mar 2007 17:07:05 +0100
- Subject: 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