Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3319104
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:47:07+00:00 2026-05-17T22:47:07+00:00

I need to disable some code when run under the debugger. So, I just

  • 0

I need to disable some code when run under the debugger.

So, I just imagine that doing:

{$IFNDEF DEBUG} 
  ...
{$ENDIF}

However, the code inside the ifndef is executed in the debugger, makin it crash.

I have lazarus 0.9.29 & FPC 2.4.0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:47:07+00:00Added an answer on May 17, 2026 at 10:47 pm

    The compiler directives that you mention are actually THAT: compiler directives, not debugging directives.

    They relate to the compilation process, witch is completely separate from the debugging system.

    What you have to do is:

    • When you want to debug the program, define the DEBUG symbol. This will NOT compile the blocks that exist inside the tests and will not run on the debugging session.
    • When you do want to release that code just un-define DEBUG and all is ready to ship.

    You are confusing compilation and debugging and putting them in the same context.
    They actually reside in complete separate contexts.
    This could be due to the fact that you compile and debug under the same GUI system, but if you compile a program the only thing the debugger looks for is break points.

    Hope it helps.

    Edit: You can define it by a Simple {$DEFINE DEBUG} somewhere at the top of your Program/Unit or use the Lazarus Options pane to add it as a command line param.

    To complete my answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For a requirement to generate per-PC license keys, I need some code which will
I need to disable specific keys (Ctrl and Backspace) in Internet Explorer 6. Is
I need to disable PUT, DELETE & TRACE HTTP requests on my Application Server,
I need to enable/disable completely network interfaces from a script in Windows XP. I'm
How do I disable the support for JavaScript keypress events in iframes? I need
I need to style links for a Blackberry browser that has disabled CSS. The
Need a function that takes a character as a parameter and returns true if
Need to an expression that returns only things with an I followed by either
I am profiling some AS code by measuring wall clock time. In order to
I'm looking to write some very timing sensitive code on an LPC1343 where I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.