View Full Version: Hope someone can help with this....

C++ Learning Community > C++ for Linux > Hope someone can help with this....


Title: Hope someone can help with this....
Description: Writing a library on a linux machine


DerelictDream - August 16, 2005 08:58 PM (GMT)
Ok... I posted this problem elsewhere and got zero help, well at least nothing that helped me with my problem...

I am writing a library as part of a venture to teach myself c++... This library was originally intended to be a part of a larger program, but for now I was just doing this part. The problem is the program seg-faults and I can't figure out why. I am posting one header, the library source, and a test program along with a makefile. I am running RH9 using gcc 4.0.0.

Thanks in advance for any help...

Oh I do get the gdb output:

Program received signal SIGSEGV, Segmentation fault.
__gnu_cxx::__exchange_and_add(int volatile*, int) (__mem=0x64, __val=-1)
at atomicity.cc:41
41 atomicity.cc: No such file or directory.
in atomicity.cc



myork - August 16, 2005 09:15 PM (GMT)

How experienced are you at C?

The first error is because you are doing
CODE
psp[i] = <SOMTHING>;

When psp is undefined. Line 27 of libpstate.cpp

A quick scan of the code reveals this is by far not youronly problem.




DerelictDream - August 16, 2005 09:45 PM (GMT)
Experienced? ummmm I'm not... I guess I can get the compiler to stop yelling at me, but thats it ;)

DerelictDream - August 16, 2005 09:51 PM (GMT)
I thought the statement
CODE

C_prog_state::psp [ i ] =
 new S_prog_state;

was the definition. Hrmmm even if I say
CODE

C_prog_state::psp = new S_prog_state*[ C_prog_state::states ];


before there, I still get a seg fault in the same place. So obviously, I have no idea how to use "new" among other things... Any pointers? (no pun intended...)




* Hosted for free by InvisionFree