With the way the codes is written
Code:
char *err_msg[] = {"Hello", "Bye", "To day"};
void usage()
{
int i;
for(i = 0; i < 3; ++i)
printf("%s\n", err_msg[i]);
}
compiles to
Code:
.data
.align 4
.type err_msg,@object
err_msg:
.long .LC0
.long .LC1
.long .LC2
.section .rodata
.LC2:
.string "To day"
.LC1:
.string "Bye"
.LC0:
.string "Hello"
.size err_msg,12
.LC3:
.string "%s\n"
The array err_msg is stored statically along with the string data. The .globl directive gives err_msg global linkage. Probably the easiest way to fix this is to code it like
Code:
static char *err_msg[] = {"Hello", "Bye", "To day"};
void usage()
{
int i;
for(i = 0; i < 3; ++i)
printf("%s\n", err_msg[i]);
}
Or you could put err_msg inside usage.