Cxx Tips

From EggeWiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

gdb

bt
set print static-members off 
info args; info locals
frame #

I'm getting this error when I run make

Makefile:62: *** missing separator.  Stop.

This is on of my favorites. It's often because you have four spaces instead of a tab prefixing the line.

How to turn on or off asserts in C++

$ cat x.c
#include <assert.h>

int main(int a, char** b) {
        assert(0);
        return 0;
}
$ gcc x.c -DNDEBUG
$ ./a.out
$ gcc x.c
$ ./a.out
Assertion failed: 0, file x.c, line 4
Abort (core dumped)

NB you will have compiled away all the asserts by defining NDEBUG!