ARM Technical Support Knowledge Articles

DEFINING A STRING ON THE COMPILER COMMAND LINE

Applies to: General Topics

Answer


Information in this article applies to:


SYMPTOM

Can I use the DEFINE command line option to pass a string to my program at compile time?

CAUSE

Though you can't pass a complete string using the DEFINE option, you can pass individual characters.

RESOLUTION

If you want define a string, you need to break it up into individual characters, as shown below.

C51 define(VERSION="'V','e','r','s','i','o','n',' ','1','.','0','b','e','t','a'")

The symbol VERSION can then be used in your C code as follows,

#ifdef VERSION
  char VersionString[] = VERSION,0;
#else
  char VersionString[] = "No Version Information";
#endif

Article last edited on: 2004-05-01 20:03:34

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