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

  • Home
  • SEARCH
  • 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

I have the following Macro I want to call from within an AutoHotkey script
Is it possible to use the __unused attribute macro on Objective-C object method parameters?
I have a 'foreach' macro I use frequently in C++ that works for most
Can you define a macro that accesses a normal variable, but in a read-only
I have seen this macro defined before but never really knew its purpose. Can
My macro updates a large spreadsheet with numbers, but it runs very slowly as
In a macro for Visual Studio 6, I wanted to run an external program,
The TRACE macro can be used to output diagnostic messages to the debugger when
Whenever I use a macro in Visual Studio I get an annoying tip balloon
I am writing a macro for Visual studio that will generate some code. I

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.