3

While debugging an iOS application, I know how to print values of objects using :

print "variable name"

po "variable name"

p "integer Variables"

I wanted to know how to print value of a constant while debugging in Xcode? Is there any command that prints value of a constant? Because, if I use the above commands, the Xcode returns an error saying

error: use of undeclared identifier

Thanks.

4
  • When you say "constant" is that const int something = 123; or #define SOMETHING 123? Commented Oct 25, 2012 at 9:08
  • 1
    No you can't. Use const int ... or typedef enum { ... } MyType; instead of pre-processor constants. Commented Oct 25, 2012 at 9:11
  • So, I cannot print the value of the macro at runtime in Xcode? Commented Oct 25, 2012 at 9:11
  • No. Using enum is better anyway. Commented Oct 25, 2012 at 9:14

2 Answers 2

10

Macros (what you get when you #define something) are the domain of the language preprocessor. They are expanded and the expanded value is used when compiling your code.

The debugger doesn't parse your source file, it works off of what's in the binary. So no, you won't be able to view the value of #define macros in the debugger.

Sign up to request clarification or add additional context in comments.

Comments

0

Old question, but nowadays compiling with -g3 (GCC) or -fdebug-macro (Clang) will generate debug information for such preprocessor macros.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.