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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:17:45+00:00 2026-06-08T11:17:45+00:00

Exactly, macro is not necessary for programming languages. For example, Java works quite fine

  • 0

Exactly, macro is not necessary for programming languages. For example, Java works quite fine without macro. Usually macro makes code more clear and shorter, at the same time, more dangerous.

So, what’s the best way to use macro?
Let’s talk in code.

  • 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-08T11:17:46+00:00Added an answer on June 8, 2026 at 11:17 am

    I use macros only in places where nothing else works.

    One example is having an easy mapping from error values to strings, for example instead of

    switch(code) {
        case ERR_OK: return "ERR_OK";
        case ERR_FOO: return "ERR_FOO";
        :
    

    I use a simple macro like

    #define CASE_STR(x) case x: return #x
    

    so I can simplify this to

    switch(code) {
        CASE_STR(ERR_OK);
        CASE_STR(ERR_FOO);
        :
    

    However, those cases are usually more for debugging.

    Also, I’ve written a GLSL (OpenGL Shading Language) loop unrolling once using the boost preprocessor suite, which then could be used something like

    const char *shader = "#version 120\n"
    "..."
    GLSL_UNROLL_FOR("int i",0,10,\
        "foo += i\n" \
    )
    "...";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a macro like this ( not exactly, but function is quite equivalent):
So I've got a macro that works nicely in GCC, but not in Microsoft's
I'm not sure what macros are. For example the following macro is found in
This is not exactly a technical question, since I know C kind of enough
McCarthy's original Lisp and some number of incarnations thereafter did not have a macro
Exactly as the title says. I've created an @NodeEntity annotated POJO and in it
Exactly what the title says...........any thoughts on other good options for relational database implementation
Exactly as the subject, How to create oval button in WPF application?
Exactly when are an Activity 's fields that are annotated with @InjectView or @InjectResource
Questions exactly like this have been asked before, i've read them all and tried

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.