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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:54:34+00:00 2026-05-15T17:54:34+00:00

If I add a macro FOO=bar under GCC_PREPROCESSOR_DEFINITIONS (or Preprocessor Macros if you use

  • 0

If I add a macro “FOO=bar” under GCC_PREPROCESSOR_DEFINITIONS (or Preprocessor Macros if you use XCode”), what would be the best way to access the value of “FOO”?

Currently, I use the clumsy:

    #define MACRO_NAME(f) #f
    #define MACRO_VALUE(f)  MACRO_NAME(f)

    #ifdef FOO
        NSLog(@"%s", MACRO_VALUE(FOO));
    #else
        NSLog(@"undefined");
    #endif

This will output “bar”

Surely, there must be a better/cleaner way?

  • 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-15T17:54:34+00:00Added an answer on May 15, 2026 at 5:54 pm

    What you are doing is the way to stringize (or stringify) macro values. The indirection is unavoidable.

    This is mentioned in the GCC preprocessor manual section (archived link) that Rob linked to:

     #define xstr(s) str(s)
     #define str(s) #s
     #define foo 4
     str (foo)
          ==> "foo"
     xstr (foo)
          ==> xstr (4)
          ==> str (4)
          ==> "4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 534k
  • Answers 533k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Passing a knownTypes arg to the DataContractSerializer constructor will not… May 17, 2026 at 12:39 am
  • Editorial Team
    Editorial Team added an answer There is a fix available on the apple dev forums,… May 17, 2026 at 12:39 am
  • Editorial Team
    Editorial Team added an answer Yes, you need to sign them again. The certificate itself… May 17, 2026 at 12:39 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I would like to have a macro which I'll call def-foo. Def-foo will create
I've noticed that sometimes, C macros are written as something like this: #define foo(bar)
I need to do an assertion based on two related macro preprocessor #define 's
I know there's a property to add in the beginning of the macro so
Can I invoke an option on a COM Add-in from a VBA macro in
Currently we developed a VB macro for word. While we tried to use it
I've been using kmacro commands such as kmacro-name-last-macro to save keyboard macros. The problem
When I try to add metadata to an infinite lazy sequence in Clojure, I
Say I have this small function in a source file static void foo() {}
I am searching for a way to determine at runtime, which type of object

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.