Keil Logo

C166: Using Macros with In-line Assembly


Information in this article applies to:

  • C166, version 5

QUESTION

I have defined the following macro that should generate an ATOMIC instruction that will block interrupts for n instructions.

#define DisableIRQ(n) __asm { atomic #n }

However, the macro does not work. The pound character ('#') is the stringize macro operator which converts n into a string.

Is there a way to avoid this?

ANSWER

Yes. Put n inside parentheses. For example:

#define DisableIRQ(n) __asm { atomic #(n) }

The parentheses prevent string conversion.

MORE INFORMATION


Last Reviewed: Thursday, February 25, 2021


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.