why do global variables lose effect

Programming, for all ages and all languages.
Post Reply
Milo
Posts: 16
Joined: Sat May 26, 2007 7:12 am

why do global variables lose effect

Post by Milo »

Hi,everyone.
When I defined global variables and local variables shown below, why would the local one work while the global one not?

Code: Select all

char		testa[10]="hello";
int main()
{
	char	testb[10]="world";
//print(testa); //Well, this piece of code doesn't print anything.
	print(testb); //when using this one instead, it works and print out "world";
..............
}
This is mapfile

Code: Select all

............
.init_array
 *(.init_array)
                0x00011000                PROVIDE (__init_array_end, .)
                0x00011000                PROVIDE (__fini_array_start, .)

.fini_array
 *(.fini_array)
                0x00011000                PROVIDE (__fini_array_end, .)

.data           0x00011000       0x16
 *(.data .data.* .gnu.linkonce.d.*)
 .data          0x00011000        0xa kernel/global.o
                0x00011000                teststring
 *fill*         0x0001100a        0x2 00
 .data          0x0001100c        0xa kernel/main.o
                0x0001100c                testa
..................
Thanks!
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

You've posted this in another forum. Don't be greedy!
Post Reply