I'm trying to compile ROM using g++ so I can make use of some OO functionality. While it compiles it crashes once I boot it. Program received signal SIGSEGV, Segmentation fault. get_room_index__Fi (vnum=3502) at db.c:2821 2821 if ( pRoomIndex->vnum == vnum ) (gdb) bt #0 get_room_index__Fi (vnum=3502) at db.c:2821 #1 0x0807047c in fix_exits__Fv () at db.c:1631 #2 0x0806eb46 in boot_db__Fv () at db.c:540 #3 0x08069202 in main (argc=2, argv=0xbffffc94) at comm.c:425 #4 0x4007f54d in __libc_start_main () from /lib/libc.so.6
I can't figure out why it crashes there. Has anybody written a guide to how to convert ROM to be g++ compatible? I'm a good programmer when it comes to languages such as Java and VB.Net, I've never really worked with C++ and g++ so I understand there is a learning curve. Thanks!
Just wondering, have you converted room_index_data into a class? I've noticed that with C++ alot of pointers initialize to a value other than NULL. In this case, the null check will pass, but the code will crash when you try to access a member.
No I never did, however comparing to the source linked above I could make it work… However I had to include <crypt.h> otherwise the crypt wouldn't work. But now it seems to be running fine, thanks for all the help guys!
There may have been some other problem at the time of the crash. It's usually a good idea to try and use GDB to figure out what might have happened.
Depending on how things worked out, pRoomIndex might not have been properly allocated and you were checking a junk pointer when it crashed. We're sort of left to assume you made no modifications to the code other than fixing compiler errors/warnings.