ARM Technical Support Knowledge Articles

USING #IF TO TEST CONDITIONS

Applies to: C51 C Compiler

Answer


Information in this article applies to:


SYMPTOMS

In A51, I can do the following:

$if (CPU=1 OR DISP=3)

with 2 or more conditions. However, in C51 I could not find a way to do this. The following code:

#if CPU==1 OR DISP==2

gives me an error message. What's wrong?

CAUSE

The #if preprocessor directive in C expects C operators to be used.

RESOLUTION

Try using the logical or operator ('||') as shown in the following.

#if CPU==1 || DISP==2

That should work.

MORE INFORMATION

Refer to a good C manual for more information about how to use the #if preprocessor directive.

Article last edited on: 2006-10-24 11:46:23

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential