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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:33:40+00:00 2026-05-30T17:33:40+00:00

When the code is burden with a lot of #if, #ifdef. Like the case

  • 0

When the code is burden with a lot of #if, #ifdef. Like the case below

#ifdef CASE1                       
#ifdef CASE1_1
#define VALUE X
#else
#define VALUE Y
#endif
#else
#define VALUE Z
#endif

Is there a way to quickly determine which branch the code will get compiled. Any suggestions are appreciated. Thanks and Best Regards

  • 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-30T17:33:42+00:00Added an answer on May 30, 2026 at 5:33 pm

    Reading nested preprocessor macros can be made easier by indenting. Most preprocessors allow:

    
    #ifdef foo
        #define bar (1)
    #endif
    

    But the following form should be universally allowed:

    
    #ifdef foo
    #    define bar (1)
    #endif
    

    While that helps follow the nest, it doesn’t guarantee that you’ll be able to spot which path is active, particularly if you are doing definitions by passing options to your compiler via -D

    One solution is to run the preprocessor over your source files and inspect the output. You can either do that by running the preprocessor executable manually (eg. cpp), or by telling your compiler to stop after running the preprocessor (eg. gcc -E)

    That is guaranteed to show you what values have been substituted for your preprocessor macros. But the output from the preprocessor can be hard to follow.

    If you’re just trying to trace a small section of code (as in your example) you can do it manually by liberally inserting #error (or #warning if your preprocessor supports it), and looking at the errors dumped from your compiler. This is typically the simplest option as you don’t have to make changes to your build system to get the visibility that you’re after.

    Another option, depending on the complexity of your preprocessor macros, is to run another preprocessor tool over your source files that will generate friendlier output than the preprocessor. I’ve had success with filepp in the past.

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

Sidebar

Related Questions

We have a lot of class code which has some boilerplate like the following:
Code below does not run correctly and throws InvalidOperationExcepiton . public void Foo() {
Code I have: cell_val = CStr(Nz(fld.value, )) Dim iter As Long For iter =
Code below is not working as expected to detect if it is in design
Code like this often happens: l = [] while foo: # baz l.append(bar) #
I am writing a numerical code, in which I would like to use a
I have a little bit of code that looks just like this: function StrippedExample(i1,
Code: %define x 0x03 x equ 0x03 What's the difference between them?
Code shown below is working in chrome and IE, but not in firefox <img
Code: <html xmlns=http://www.w3.org/1999/xhtml> <head> <title>Unusual Array Lengths!</title> <script type=text/javascript> var arrayList = new Array();

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.