Problem when accessing variables
Hiep Tran
hiep at netvisiontel.co.kr
Tue Mar 29 14:11:16 EST 2005
Hi all,
I just joint to embedded software world and I am facing with a problem
related to ppc_405-gcc compiler. My problem is my source code if compiled by
gcc compiler and run on Linux platform, everything is OK, but if my source
code is compiled with ppc_405-gcc and transfering to Power PC and to be run,
I am always facing with "pointer problem" described as follows:
I have file called "hashtable.c", which contains some functions to
manipulate a structure in C programming language (it's really a hashtable
structure, which I am implementing). These functions include adding,
removing, lookupping etc on a input pointer parameter, which point to a
hashtable structure.
I have another file called "test.c", which will use functions of hashtable,
which mentioned above. And in this file, I can manipulate my hashtable
structure by calling functions in file "hashtable.c" only. But if I access
to members of hashtable structure or hashtable's node structure directly
(without calling hashtable functions to receive these structure's members)
then my test program is always died by a invalid pointer, which is referring
to structure's member. the test.c and hashtable.c files were compiled and
linked together.
But if I copy all functions in hashtable.c and paste to test.c and then
compile, create my program by using the test.c file only the my test program
is run well.
I think my problem related to linking between object files (it's seem to me
that, pointers, which are allocated memory, or global variables declared in
this file will cause problem when access it in another file) on ppc_405-gcc
compiler because my problem is still run well on Linux computer when it was
compiled and linked by gcc compiler.
My temporary solution is I added a new function to the file hashtable.c,
this function returns data members, which reside inside node structures of
hashtable structure and I can access these data pointers without facing any
problem.
Anyone could give me any option to set to ppc_405-gcc compiler or any
solution to help to me passing the problem.
Thanks,
Hiep Tran
More information about the Linuxppc-embedded
mailing list