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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:37:40+00:00 2026-05-23T02:37:40+00:00

I am a bit confused on the type of expression we can use with

  • 0

I am a bit confused on the type of expression we can use with the #IF preprocessor in the C language. I tried the following code, and it isn’t working. Please explain and provide examples for expressions that can be used with the preprocessor.

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

int c=1;

#if c==1
    #define check(a) (a==1)?a:5
    #define TABLE_SIZE 100
#endif

int main()
{
    int a = 0, b;
    printf("a = %d\n", a);
    b = check(a);
    printf("a = %d %d\n", a, TABLE_SIZE);
    system("PAUSE");
    return 0;
}
  • 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-23T02:37:40+00:00Added an answer on May 23, 2026 at 2:37 am

    The preprocessor cannot use variables from the C program in expressions – it can only act on preprocessor macros. So when you try to use c in the preprocessor you don’t get what you might expect.

    However, you also don’t get an error because when the preprocessor tries to evaluate an identifier that isn’t defined as a macro, it treats the identifier as having a value of zero.

    So when you hit this snippet:

    #if c==1
    #define check(a) (a==1)?a:5
    #define TABLE_SIZE 100
    #endif
    

    The c used by the preprocessor has nothing to do with the variable c from the C program. The preprocessor looks to see if there’s a macro defined for c. Since there isn’t, it evaluates the following expression:

    #if 0==1
    

    which is false of course.

    Since you don’t appear to use the variable c in your program, you can do the following to get behavior in line with what you’re trying:

    #define C 1
    
    #if C==1
    #define check(a) (a==1)?a:5
    #define TABLE_SIZE 100
    #endif
    

    (Note that I also made the macro name uppercase in keeping with convention for macro names.)

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

Sidebar

Related Questions

I am bit confused about implicit type conversion. Given the following program float x
hi i am little bit confused in valu type or referance type... for instance
Perhaps I'm a bit confused about when to use the waitForPageToLoad command, but what
I am a bit confused on when to use CC_CONTENT_SCALE_FACTOR() in my app. I
I am a bit confused about the nth-of-type pseudo class, and how this is
I'm a bit confused by the difference in type-checking between curried and uncurried generic
I'm getting a bit confused by the behaviour of the SQL DATE data type
I'm a bit confused here. I wrote the following script to add files of
I am a bit confused about the objects which are initialized by type-casting. Like
I am bit confused on how to use the iTunes app icon when getting

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.