DEUG vs RELEASE

  • Greetings.

    I want to do some console logging when i'm in debug mode.
    but in release, of course, none (xept errors).

    in delphi i used to check it like this

    #IFDEF DEBUG
    // do my debug related code here
    #ENDIF

    is there such an easy way to do it in Xcode ?

    thanks.

    Sandro Noel
    <snoel...>
  • Yes, exactly what you just typed.

    Mike.

    On 8 Oct 2007, at 21:57, Sandro Noel wrote:

    > Greetings.
    >
    > I want to do some console logging when i'm in debug mode.
    > but in release, of course, none (xept errors).
    >
    > in delphi i used to check it like this
    >
    > #IFDEF DEBUG
    > // do my debug related code here
    > #ENDIF
    >
    > is there such an easy way to do it in Xcode ?
    >
    > thanks.
    >
    > Sandro Noel
    > <snoel...>
  • Am 08.10.2007 um 22:57 schrieb Sandro Noel:
    > I want to do some console logging when i'm in debug mode.
    > but in release, of course, none (xept errors).
    >
    > in delphi i used to check it like this
    >
    > #IFDEF DEBUG
    > // do my debug related code here
    > #ENDIF
    >
    > is there such an easy way to do it in Xcode ?

      Not quite, I think, but you can use the "Preprocessor Macros" build
    setting to define these constants (set it to "DEBUG=1 RELEASE=0" and
    vice versa, for example), and you can do so separately for the
    Release and Debug build configurations. And then you can do

    #if DEBUG
    #define dprintf(...)    printf(__VA_ARGS__)
    #else
    #define dprintf(...)    // nothing
    #endif

    and the likes.

    Cheers,
    -- M. Uli Kusterer
    http://www.zathras.de
  • --- Sandro Noel <snoel...> wrote:

    > Greetings.
    >
    > I want to do some console logging when i'm in debug
    > mode.
    > but in release, of course, none (xept errors).
    >
    > in delphi i used to check it like this
    >
    > #IFDEF DEBUG
    > // do my debug related code here
    > #ENDIF
    >
    > is there such an easy way to do it in Xcode ?

    In your debug configuration, add "DEBUG=1" to the
    preprocessor macros. Then you can do #ifdef debug.

    Cheers,
    Chuck


    ____________________________________________________________________________________
    Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out.
    http://answers.yahoo.com/dir/?link=list&sid=396545469
  • Mike,

      that's wrong. First, the DEBUG constant is not automatically
    defined, and second, the C preprocessor only accepts #ifdef and
    #endif, #IFDEF and #ENDIF will give you an error message about an
    unrecognized preprocessor directive.

    Am 08.10.2007 um 23:08 schrieb Mike Abdullah:
    > Yes, exactly what you just typed.
    >
    > Mike.
    >
    > On 8 Oct 2007, at 21:57, Sandro Noel wrote:
    >
    >> Greetings.
    >>
    >> I want to do some console logging when i'm in debug mode.
    >> but in release, of course, none (xept errors).
    >>
    >> in delphi i used to check it like this
    >>
    >> #IFDEF DEBUG
    >> // do my debug related code here
    >> #ENDIF
    >>
    >> is there such an easy way to do it in Xcode ?
    >>
    >> thanks.
    >>
    >> Sandro Noel
    >> <snoel...>


    Cheers,
    -- M. Uli Kusterer
    http://www.zathras.de
  • thank you for all your answers

    Is there a way to DEFINE these in the Build configuration ?

    Sandro Noel
    <snoel...>

    On 8-Oct-07, at 5:11 PM, Uli Kusterer wrote:

    > Am 08.10.2007 um 22:57 schrieb Sandro Noel:
    >> I want to do some console logging when i'm in debug mode.
    >> but in release, of course, none (xept errors).
    >>
    >> in delphi i used to check it like this
    >>
    >> #IFDEF DEBUG
    >> // do my debug related code here
    >> #ENDIF
    >>
    >> is there such an easy way to do it in Xcode ?
    >
    > Not quite, I think, but you can use the "Preprocessor Macros"
    > build setting to define these constants (set it to "DEBUG=1
    > RELEASE=0" and vice versa, for example), and you can do so
    > separately for the Release and Debug build configurations. And then
    > you can do
    >
    > #if DEBUG
    > #define dprintf(...)    printf(__VA_ARGS__)
    > #else
    > #define dprintf(...)    // nothing
    > #endif
    >
    > and the likes.
    >
    > Cheers,
    > -- M. Uli Kusterer
    > http://www.zathras.de
    >
    >
    >
    >
  • On Oct 8, 2007, at 2:53 PM, Sandro Noel wrote:

    > thank you for all your answers
    >
    > Is there a way to DEFINE these in the Build configuration ?

    Yes.  In C (and therefore Objective-C) these are called "preprocessor
    macros," so you can set them in the "Preprocessor Macros" build
    setting of the appropriate build configuration.

    You'll probably want to set them in your build configurations at the
    project rather than at the target level, so that they apply to all
    targets in your project.  Build settings, build configurations, and
    how they work are covered in the Xcode documentation.

      -- Chris
  • Am 08.10.2007 um 23:53 schrieb Sandro Noel:
    > thank you for all your answers
    >
    > Is there a way to DEFINE these in the Build configuration ?

    Yes. Use the "Preprocessor Macros" build setting, as I mentioned. You
    find the build settings in the project settings or target settings.

    BTW -- Xcode has some pretty well-written documentation, see the
    "Help" menu.

    Cheers,
    -- M. Uli Kusterer
    http://www.zathras.de
  • Chris, thank you for a very clear answer.
    it is very appreciated.

    Sandro Noel
    <snoel...>

    On 8-Oct-07, at 6:08 PM, Chris Hanson wrote:

    > On Oct 8, 2007, at 2:53 PM, Sandro Noel wrote:
    >
    >> thank you for all your answers
    >>
    >> Is there a way to DEFINE these in the Build configuration ?
    >
    > Yes.  In C (and therefore Objective-C) these are called
    > "preprocessor macros," so you can set them in the "Preprocessor
    > Macros" build setting of the appropriate build configuration.
    >
    > You'll probably want to set them in your build configurations at
    > the project rather than at the target level, so that they apply to
    > all targets in your project.  Build settings, build configurations,
    > and how they work are covered in the Xcode documentation.
    >
    > -- Chris
    >
    >
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today