Keil Logo

GENERAL: CONVERTING MACRO PARAMETERS TO STRINGS


Information in this article applies to:

  • C166 Version 3.12
  • C166 Version 4.10a
  • C251 Version 1.24
  • C251 Version 2.14
  • C251 Version 3.00
  • C51 Version 5.50a
  • C51 Version 6.10a

QUESTION

How do I convert a constant passed to a #define macro into a text string?

ANSWER

Pass the parameter to a stringizing macro as shown below:

#define NUMBER B85800    // this can be defined in the command line

#define VAL(str) #str
#define TOSTRING(str) VAL(str)

unsigned char part1[10] = TOSTRING (NUMBER); // generates "B85800"
unsigned char part2[10] = VAL(NUMBER);       // generates "NUMBER"

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Monday, March 19, 2001


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.