Results 1 to 4 of 4

Thread: Ifdefs

  1. #1

    Ifdefs

    Currently using FPC 2.2.4, and I've found these lovely things called IFDEFs.
    Ex:
    Code:
    {$IFDEF FPC}
     {$MODE DELPHI}
    {$ENDIF}
    Is there any way for me to define my own variables for these? I'd like to create an {$IFDEF DEBUG} so that the code won't be compiled and run in the final application, whereas just having a "if(debug) then" everywhere will be compiled and will be executed.

  2. #2

    Re: Ifdefs

    Yes, you can
    Something like this should do the trick
    [code=pascal]
    {$define MyDebug}

    {$ifdef MyDebug}
    writeln('Debugging...');
    {$endif}
    [/code]

    Look also at http://community.freepascal.org:1000...l#x106-1060002
    Get your fpc4gba copy now!
    Get your fpc4nds copy now!

  3. #3

    Re: Ifdefs

    Quote Originally Posted by dazappa
    ... whereas just having a "if(debug) then" everywhere will be compiled and will be executed.
    That is unless compiler optimizes it out. If your debug variable is constant it just might do that but i'm not sure.

  4. #4

    Re: Ifdefs

    Quote Originally Posted by Legolas
    Yes, you can
    Something like this should do the trick
    [code=pascal]
    {$define MyDebug}

    {$ifdef MyDebug}
    writeln('Debugging...');
    {$endif}
    [/code]

    Look also at http://community.freepascal.org:1000...l#x106-1060002
    Thanks. The info on that link (+ ifdefs) seem oh-so-helpful. But, currently I really only needed/wanted the ifdefs but I'm sure I'll have a use for the others in the future.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •