Keil Logo

C51: USING #IF TO TEST CONDITIONS


Information in this article applies to:

  • C251 Version 2.14
  • C51 Version 5.50

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 #if in the Cx51 User's Guide.

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

Last Reviewed: Tuesday, October 24, 2006


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.