Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Nimboz

macrumors newbie
Original poster
Aug 30, 2008
4
0
Hi,

I'm an absolute beginner in C and have just started using Xcode recently. It works great, but one functionality I miss from the years old "Turbo C++" is tracing the steps — on a keypress it would highlight which codeblock/statement will be executed in sequence. VERY VERY helpful for beginners like me to understand how things work.

I'm sure something similar must be available in XCode?

Thanks in advance.
 
Set a debugger breakpoint. You can then step through the code one line at a time.

Erm..how to do that?

btw, in Turbo C, you don't have to set beakpoints, it just shows you how the compiler will execute the code step by step.

Many thanks
 
I don't know of any "Build and debug, and break on first line" option in Xcode.

It probably doesn't make much sense to have one, in your average Cocoa app, as the 'entry point' is a little vague. Where would the first "auto breakpoint" be? In main.m, you'd be stepping into assembly code in NSApplicationMain(). If the breakpoint was in applicationDidFinishLaunching, you might miss some other code block you wanted to debug before that.

Hence, it probably makes the most sense to set the first breakpoint yourself. If that's the only problem you're having with Xcode, you're doing well (a lot better than I did! :) )
 
You're starting to run into the difference between a CLI app and a GUI app. In CLI apps, your users wait for your program. In GUI apps, your program waits for your users. Because of this, you don't really know what's going to get executed first, aside from the stuff in main()--but that will be the same 99% of the time.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.