Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

Beginner C programming questions regarding Preprocessors

Hi,
 I was studying the preprocessors in C and have a simple question.

For a simple program

#define TEST_INS
#define TEST_ACC
#define TRUE 1
#define FALSE 2

#ifdef TEST_INS
int maintest()
{
  int b;
  #ifdef TEST_ACC
   printf("The testa_acc is true");
   b=TRUE;
  #else
   printf("The testa_acc is false");
   b=FALSE;
  #endif
 return b;
}
#endif

The statement that sets the value of b is determined compile time or runtime?

From what I understand all preprocessors commands are executed prior to compile time, but in this case when will the value of "b" be set?

Any help would be appreciated.

Thanks

cbeginner
0
cbeginner
Asked:
cbeginner
  • 2
  • 2
1 Solution
 
tinchosCommented:
the value of b is determined after the preprocessor

after the preprocessor run the code is like this

int maintest()
{
 int b;
  printf("The testa_acc is true");
  b=1;
return b;
}
0
 
cbeginnerAuthor Commented:
Thank you tinchos for your reply. So the value of b is set at "compile time" correct.

0
 
tinchosCommented:
ok

then you just have to accept the comment as answer and grade it
0
 
cbeginnerAuthor Commented:
Very prompt answer thanks tinchos.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now