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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:44:48+00:00 2026-05-16T05:44:48+00:00

I feel, every time I read a C or C++ program, that half or

  • 0

I feel, every time I read a C or C++ program, that half or more of it is just macros. I understand that macros can be cool but they are hard to track, debug, etc. Not to mention that most programming languages do not even define something like macros (although Perl6 will have something of the sort).

I personally always have found a way to write my code without using macros, whether it be with templates, multiple inheritance, etc. I have even felt I am not a good programmer because all the pros use macros and I try to avoid them as much as I can.

The question is, are there problems which cannot be solved without macros? Are macros ultimately a good/bad practice? When should I consider using a macro?

  • 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-16T05:44:49+00:00Added an answer on May 16, 2026 at 5:44 am

    Yes, here’s one. When you need to add tracing code to your program in such a way that one configuration contains it and the other completely omits you have to use macros.

    Something like:

    #ifdef WITH_LOGGING
        #define LOG( x ) DoLog( x )
    #else
        #define LOG( x )
    #endif
    

    now you use it this way:

    LOG( L"Calling blahblahblah with " + getSomeStringHardToCompute() );
    

    and in the configuration with WITH_LOGGING you have that code and otherwise it is completely omitted – not even present in the binary, and therefore

    • it doesn’t help others analyze your program
    • you get a smaller binary
    • the program doesn’t waste time fo logging at all
    • the compiler can produce better optimized code.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can understand using properties for messages and international settings but I feel there
As an amateur mobile developer, I feel dismay every time I have to fix,
I feel like I've only ever seen this here on SO, but I can't
I'm working with SOAP::WSDL and another company's custom WSDL file. Every time they make
I'm playing around with UIbuttons, just to get a feel on what can really
Every time I have to get an element that might not exist from an
I need a function that triggers an event every time every time a word
I can't seem to figure out this SimpleCursorAdapter , every time I fix one
This isn't the best question ever, but since search engines feel the need to
Feel free to close and/or redirect if this has been asked, but here's my

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.