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
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.
Experienced? ummmm I'm not... I guess I can get the compiler to stop yelling at me, but thats it ;)
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...)