This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Compiling only the code under IF part in C

Hi All,

Till now I have written code in assembly language for 8051 controller. Now I would like to write code in C. Here I have a problem. I will explain it clearly.

When I write code in assembly, I used to write assembler directives. In that there is a provision to compile only the if part like below:

In INITPARA.INC (contains all the parameters), i will declare

VER1_0: EQU NO
VER1_1: EQU YES

In other ASM program, I will write like below:

IF(VER1_1 = YES) THEN STATEMENT 0 STATEMENT 1 STATEMENT 2
ELSE STATEMENT 3
ENDIF

Now, when I compile, only code under IF part i.e., STATEMENT 0, STATEMENT 1, STATEMENT 2 are compiled. If I equate VER1_0 to YES and VER1_1 to NO in INITPARA.INC then only code under ELSE part is compiled (STATMENT 3). This is a very good feature.

Is it possible to do the same in C. If not, size of my hex file will be increasing by every version

regards,
Bhavani Shankar S

0