?
Solved

Beginner C programming questions regarding Preprocessors

Posted on 2003-02-23
4
Medium Priority
?
259 Views
Last Modified: 2010-04-15
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
Comment
Question by:cbeginner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:tinchos
ID: 8005546
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
 

Author Comment

by:cbeginner
ID: 8005579
Thank you tinchos for your reply. So the value of b is set at "compile time" correct.

0
 
LVL 9

Accepted Solution

by:
tinchos earned 200 total points
ID: 8005595
ok

then you just have to accept the comment as answer and grade it
0
 

Author Comment

by:cbeginner
ID: 8005603
Very prompt answer thanks tinchos.
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question