[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Strings: escape sequence to insert arbitrary hex valu

From: Daniel O'Connor
Subject: Re: [avr-gcc-list] Strings: escape sequence to insert arbitrary hex value ?
Date: Thu, 5 Feb 2009 16:28:55 +1030
User-agent: KMail/1.10.3 (Linux/2.6.27-11-generic; KDE/4.1.3; i686; ; )

On Thursday 05 February 2009 15:53:50 Vincent Trouilliez wrote:
> On Thu, 5 Feb 2009 15:18:44 +1030
> "Daniel O'Connor" <address@hidden> wrote:
> > You can define it like so..
> > #define  LCD_CUSTOM_CHAR_FOO "\012"
> >
> > then you can do..
> > char example[] = "foo" LCD_CUSTOM_CHAR_FOO "bar";
> >
> > You might be able to do something more clever but I don't know how :)
> Thanks Daniel (and Ivan as well, off-list), that worked a treat ! :-)
> Only drawback I found, is that I must now have TWO #defines for each and
> every custom character: one #define to represent the character as a
> string, so I can embed it into a string, and also all the #defines I
> already had, which represent the actual numerical value, for when I
> need to print an individual/discrete character rather than print a
> string. It's not the end of the world, but not very elegant either, so
> if anybody has a solution to make do with only one define per character,
> I am all ears ;-)

I had a go at getting that to work with preprocessor magic but I don't think 
it's possible (I'm no CPP guru though).

Actually, how about..

#define FOO "\070"
#define getOrd(x) (x)[0]

I only compiled it on a PC so I don't know if it would be optimised down to 
what you expect but I think it would be.

Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C

Attachment: signature.asc
Description: This is a digitally signed message part.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]