Keil Logo

GENERAL: DEFINING A STRING ON THE COMPILER COMMAND LINE


Information in this article applies to:

  • C51 All Versions
  • C166 All Versions
  • C251 All Versions

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

MORE INFORMATIO

SEE ALSO

Last Reviewed: Wednesday, February 28, 2018


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.