ARM Technical Support Knowledge Articles

CONVERTING MACRO PARAMETERS TO STRINGS

Applies to: General Topics

Answer


Information in this article applies to:


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"

Article last edited on: 2001-03-19 00:00:00

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