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 6936829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:17:05+00:00 2026-05-27T12:17:05+00:00

Debugging macros can take a lot of time. We are much better off avoiding

  • 0

Debugging macros can take a lot of time. We are much better off
avoiding them except in the very rare cases when neither constants,
functions nor templates can do what we want.

What are the rare cases?

  • 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-27T12:17:06+00:00Added an answer on May 27, 2026 at 12:17 pm

    If you want actual textual replacement, that’s where you use macros. Take a look at Boost.Preprocessor, it’s a great way to simulate variadic templates in C++03 without repeating yourself too much.

    In other words, if you want to manipulate the program code itself, use macros.

    Another useful application is assert, which is defined to be a no-op when NDEBUG is not defined (usually release mode compilation).

    That brings us to the next point, which is a specialization of the first one: Different code with different compilation modes, or between different compilers. If you want cross-compiler support, you can’t get away without macros. Take a look at Boost in general, it needs macros all the time because of various deficiencies in various compilers it has to support.

    Another important point is when you need call-site information without wanting to bug the user of your code. You have no way to automatically get that with just a function.

    #define NEEDS_INFO() \
      has_info(__FILE__, __LINE__, __func__)
    

    With a suitable declaration of has_info (and C++11/C99 __func__ or similar).

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

Sidebar

Related Questions

Debugging a PHP program, is there any add-on/plug-in for browser which I can view
This is a more theoretical question about macros (I think). I know macros take
This is useful for debugging (hence programming related). On linux, we can use the
Can anyone recommend a quality C++ memory debugging API or software for Windows(specifically, one
Debugging an app which queries SQL Server 05, can't change the query but need
I have inherited code which contains debugging macros. #define DEBUG_LEVEL_NONE 0 #define DEBUG_LEVEL_ONE 1
I have written a debugging macro and wished to include the time in it,
I've got a weird macro that I'm debugging and I can't seem to figure
The project I'm working on has a lot of telemetry and debugging mechanisms built
When you are debugging, it's very useful to do this: var = calc() print(var:,

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.