The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,512 other followers

Never ever put OutpugDebugString in code that is meant to run on production systems

Posted by jpluimers on 2018/12/18

I just saw this code in the Delphi RTL enabled for RELEASE builds of the procedure TThreadPool.TQueueWorkerThread.Execute; code:

{$IFDEF MSWINDOWS}
    OutputDebugString(PChar(Format('Thread Exiting: %d', [ThreadId])));
{$ENDIF}

Never, ever do this.

If you code review code that contains it: ensure it has some kind of compile time DEBUG conditional around it.

–jeroen

12 Responses to “Never ever put OutpugDebugString in code that is meant to run on production systems”

  1. baka0815 said

    Why?
    I understand that you should us compile time conditionals,but what is so bad about that?

    • jpluimers said

      See the reply to Luca for more background information.

      Indeed: always have a conditional define around it that is never turned on by default;

  2. Luca said

    Sorry, can you explain why? It’s slow or dangerous?

  3. LEIF UNEUS said

    From Rio back to at least XE8.

  4. edwinyzh said

    Nice find Jeroen. Which version of it?

    • jpluimers said

      My guess is all. Since them disabling my MVP was done by just deleting the account that also held my Tech-Partner bits, I don’t have a full history of Delphi versions any more.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: