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

  • SEARCH
  • Home
  • 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 8244917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:01:03+00:00 2026-06-07T22:01:03+00:00

For debug logging, I have often seen and used something like #ifdef DEBUG #define

  • 0

For debug logging, I have often seen and used something like

#ifdef DEBUG
    #define DLOG(fmt, args...) printf("%s:%d "fmt,__FILE__,__LINE__,args)
#else
    #define DLOG(fmt, args...)
#endif

but in a number of places, I have seen the second #define replaced with

#define DLOG(fmt, args...) do {} while (0)

In particular, there’s this answer, and the comment on this other answer to the same question suggests that the problem would be in a situation like

if (condition)
    DLOG("foo");

though my quick test suggests that the resulting semicolon on the line by itself will serve as the no-op statement inside the conditional.

Is one or the other of nothing and do {} while (0) better? If so, why? Is there something else that’s even better?

  • 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-06-07T22:01:04+00:00Added an answer on June 7, 2026 at 10:01 pm

    See C #define macro for debug printing for an explanation of why you want a different form of no-op. You want to have the compiler parse the debug printing code even when you aren’t using it so that errors do not creep in.

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

Sidebar

Related Questions

Something like this: if self.__class__ == User: logging.debug(%s non_pks were found % (str(len(non_pks))) )
I have two printf style debug logging functions ( DebuglogfA , DebuglogfB ). Both
In my django views i have the following def create(request): query=header.objects.filter(id=a)[0] a=query.criteria_set.all() logging.debug(a.details) I
I'm using Pantheios library for logging. I have: pantheios::log(pantheios::debug, I'm debug); pantheios::log(pantheios::informational, Some info);
Debug HTTP is easy, you have all sort of tools to do it (like
I have the logging module MemoryHandler set up to queue debug and error messages
I have the following python code: import logging import logging.config logging.config.fileConfig('a.conf') logging.debug('aaaa') with the
All, I have the following in my views.py def getgradeform(request): id1=request.user.get_pf().id sc=Sc.objects.filter(id=id1) logging.debug(sc) logging.debug(++++)
I would like to know how can I enable debug-level logging with Axis 2
It seems logging.debug() doesn't appear in GAE logs, but logging.error() does. Does anyone have

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.