The last time I wrote something in C++ was 10 years ago during the lab session in the university, and recently I just decided to write my thesis project in C++ because of many reasons. First time writing after 10 years wasn't so easy and I got this error message on the screen when running the code:
Segmentation fault: 11
Not so helpful, is it? Meaning some errors relating to pointer happened somewhere in the program.
In Java (and probably many other modern programming languages too) usually a complete stack trace will be printed at least on the stdout, even if it's the programmer's fault for not catching the exception. Apparently in C to debug something like this there is a tool called GDB that can be easily installed in linux. On Mac it can be installed from brew, followed by a simple step of adding keychain access for gdb.
So to install:
- brew tap homebrow/dupes
- brew install gdb
- Open /Applications/Utilities/Keychain Access and create a certificate in "System". Things to highlight here are (chronologically):
- Identity type: Self signed root
- Certificate type: code signing
- Let me override defaults
- Store in "System"
- gdb [name of executable]
- up to this point the program will run and print out line number where the error happened and if need more information use backtrace.