1. Yes and no. The option "produce debugging symbols" does just what its title says, nothing else. Generally, this should not matter much, but gcc has a few peculiarities, for example, it is very well possible to generate debugging symbols and turn on optimisations at the same time. Yes, this actually works, gdb explicitely supports debugging optimised code. :shock:
Another difference is that
not enabling "produce debugging symbols" does not dead-strip
asserts as you might possibly expect.
By definition, nothing inside an
assert() statement is evaluated in a release build. This is implemented using the
NDEBUG constant.
2. You can use whatever you want, the best thing would be to use
#ifndef NDEBUG, however, since this is "standard".
3. First, enable "show all compiler warnings" (
-Wall) and "produce debugging symbols". Whenever the compiler complains about something (due to
-Wall), change your code so it passes without a warning. Many things will seem very pedantic to you, but trust me, it is for your own good. If the compiler tells you "hey this does not look right", then it is not right
When your program is mature enough for a release, enable optimsations (simply
-O2 or
-O3 will do), and remove "produce debugging symbols" or simply enable "strip executable" (that will remove the symbols either way).