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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:27:50+00:00 2026-05-16T03:27:50+00:00

In a C macro, is it possible to capitalize a pasted-in token? For example,

  • 0

In a C macro, is it possible to capitalize a pasted-in token? For example, I currently have the following macro:

#define TEST(name, keyword) \
    test_##name:
        TEST_##keyword##_KEYWORD

I would invoke this as follows:

TEST(test1, TEST1)

which would yield the following:

test_test1:
    TEST_TEST1_KEYWORD

Now, instead of having to type the same name twice (once with all lower case characters, and again with all upper case characters), is there any way that I could do either of the following, and either change the token into all uppercase letters or all lowercase letters?

TEST(test1) or TEST(TEST1)

Thanks,
Ryan

  • 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-16T03:27:50+00:00Added an answer on May 16, 2026 at 3:27 am

    As far as I’m aware, the only operations that can be done on tokens in the C preprocessor (at least ISO/ANSI standard) is to replace, ‘stringify’ or concatenate them. I’m also unaware of any GCC or MSVC extensions that will let you do what you want.

    However, people have been coming up with clever (or oddball) ways to do magical (or horrible) things with macros, so I wouldn’t be surprised if someone surprises me.

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

Sidebar

Related Questions

Possible Duplicate: Problem with Macros Hi all I have defined this macro: #define SQ(a)
Possible Duplicates: What’s the use of do while(0) when we define a macro? Why
With gcc (and possibly other compilers as well) it's possible to define a macro
Is it possible to concatenate string from another macro when #including a file name
is it possible to have a shortcut like ctrl+p to run a certain macro?
I was wondering if it was possible to define a macro in C++ that
Possible Duplicates: What’s the use of do while(0) when we define a macro? Why
Is it possible to define a macro in my Spring application context XML file
Is it possible to have a function or macro to return variable type? I
Possible Duplicates: Why would someone use #define to define constants? difference between 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.