Reputation: 861
I'm developing a c++ application with Xcode 3.1.4 while debugging, if i step into a constructor, i see only the membervariables, but no locals used in the constructor.
does anyone know that problem and how to solve it?
Upvotes: 0
Views: 217
Reputation: 11
I saw somewhere else that -gstabs+ solves a similar problem specific to locals in constructors. I didn't try it but the solution that worked for me was to move the body of the code into a private function with the same arguments, and call that function from the constructor. Same behavior, but now you can debug the code...
Upvotes: 1
Reputation: 299495
Obvious question: you're running with no optimizations (-O0), correct? With optimizations, it is very common for local variables to be optimized out. Even without optimizations, I have found that a lot of simple C++ seems to get hidden. For instance, you can't always call get()
on a shared_ptr because it gets inlined.
I recommend upgrading to Xcode 3.2. I feel that C++ support improved somewhat between 3.1 and 3.2. That said, C++ support within Xcode is still very weak. Unless you need the portability of C++ (as I do), I do not recommend developing Mac or iPhone apps in C++. You will fight the system all day. It is far better to just learn ObjC and use it (besides, ObjC really is a very powerful language and works extremely well with Cocoa). Even when you need the portability of C++, I recommend isolating the C++ code into a core and wrapping it up in Objective-C.
In no case should you use much ObjC++. gdb gets extremely confused in my experience with ObjC++. If you're going to write in C++, wrap your ObjC. If you're going to write in ObjC, wrap your C++. But don't try to write in both at the same time if you ever plan to use the debugger.
Upvotes: 0