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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:42:24+00:00 2026-06-11T01:42:24+00:00

A macro definition: #define HTTP_ERRNO_MAP(XX) \ /* No error */ \ XX(OK, success) \

  • 0

A macro definition:

#define HTTP_ERRNO_MAP(XX)                                           \
  /* No error */                                                     \
  XX(OK, "success")                                                  \
                                                                     \
  /* Callback-related errors */                                      \
  XX(CB_message_begin, "the on_message_begin callback failed")       \
  XX(CB_url, "the on_url callback failed")                           \


/* Define HPE_* values for each errno value above */
#define HTTP_ERRNO_GEN(n, s) HPE_##n,
enum http_errno {
  HTTP_ERRNO_MAP(HTTP_ERRNO_GEN)
};
#undef HTTP_ERRNO_GEN

After expand it by “gcc -E”,

enum http_errno {
  HPE_OK, HPE_CB_message_begin, HPE_CB_url,};

How does the macro expand to the result?

  • 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-11T01:42:26+00:00Added an answer on June 11, 2026 at 1:42 am

    HTTP_ERRNO_MAP(XX) will substitute XX with HTTP_ERRNO_GEN and therefore call the HTTP_ERRNO_GEN(n, s) macro 3 times:

    HTTP_ERRNO_GEN(OK, "success")
    HTTP_ERRNO_GEN(CB_message_begin, "the on_message_begin callback failed")
    HTTP_ERRNO_GEN(CB_url, "the on_url callback failed")
    

    HTTP_ERRNO_GEN(n, s) simply takes the actual text of the first argument and concatonates it (##n) with a HPE out the front and a comma at the end. Therefore the three commands above will produce the following three outputs:

    HPE_OK,
    HPE_CB_message_begin,
    HPE_CB_url,
    

    Therefore when expanded by the preprocessor,

    enum http_errno {
      HTTP_ERRNO_MAP(HTTP_ERRNO_GEN)
    };
    

    becomes (+- whitespace):

    enum http_errno {
       HPE_OK,
       HPE_CB_message_begin,
       HPE_CB_url,
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was browsing some code and I came across this macro definition #define D(x)
What does this macro do? I am not able to understand its definition: #define
I am working on a project and the code contains a macro definition: #define
Does anyone know if and/or how you can define macro definitions in a gSoap
I have a macro definition in header file like this: // header.h ARRAY_SZ(a) =
I need a definition for a macro-like string in php which would literally be
I have the following macro: #define testMethod(a, b) \ if (a.length > b.length) \
I have the following macro: ‎#define GTR(type) \‎ type type##_gtr(type a, type b) \‎
I'm trying to work out a macro definition that will turn a record into
I am looking for a strange macro definition, on purpose: I need a macro

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.