03.12.2012 Views

C++ for Scientists - Technische Universität Dresden

C++ for Scientists - Technische Universität Dresden

C++ for Scientists - Technische Universität Dresden

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

236 CHAPTER 10. PROGRAMMING TOOLS<br />

The -DNDEBUG option sets the C-preprocessor variable NDEBUG which tells the assert command<br />

that debug tests should not be done. This allows us to save time at execution.<br />

10.2 Debugging<br />

10.2.1 Debugging with text tools<br />

“Et la tu t’dis que c’est fini<br />

car pire que ça ce serait la mort.<br />

Qu’en tu crois enfin que tu t’en sors<br />

quand y en a plus et ben y en a encore!”<br />

— Stromae.<br />

There are several debugging tools. In general, graphical ones are more user friendly, but they<br />

are not always available. In this section, we describe the gdb debugger, which is very useful to<br />

trace the cause of a run time error if the code was compiled with the option -g.<br />

The following contains a printout of a gdb session of the program hello.cpp:<br />

#include <br />

#include <br />

int main() {<br />

glas::dense vector< int > x( 2 ) ;<br />

x(0) = 1 ; x(1) = 2 ;<br />

<strong>for</strong> (int i=0; i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!