Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For reference, I am a JavaScript developer learning C++. The browser is a pretty powerful debugger, and I can easily place a breakpoint in my code, hover over a variable or expression and get the value of that expression. Is this even possible in C++ or am I in a different world entirely?

I'm starting to write a bit of C++ code for an online course, and debugging with Code::Blocks gives me very opaque information. For example, I see stuff like this: 0x8049bc3 push ebp in the 'watches' window. Even if I write something like int foo = 3;, I have found no way of telling that foo is 3 while I'm stepping through my code. Am I missing something?

share|improve this question
up vote 10 down vote accepted

You need to build a debug version of your program:

Make sure that the project is compiled with the -g (debugging symbols) compiler option on, and the -s (strip symbols) option off. This ensures that the executable has debug symbols included. Compiler optimization switches should be turned off, stripping symbols (-s) must be turned off.

C++ compiles into machine code, where variables are just memory addresses. Symbols, such as variable names, can be appended to the executable by using appropriate compiler flags.

share|improve this answer
+1 when dealing with a machine code compiled language, you need a debug version. Machine instructions are just that, debug symbols are metadata which a debugger can convert into human-friendly symbols. – Snowman May 7 '14 at 5:55
There's also a huge difference in how comfortable and easy debugging is across IDEs. Try using Visual Studio once - everything is sadly a step down from there. – Ela782 May 10 '14 at 19:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.