avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] long character constants like 'abcd'


From: Egil Kvaleberg
Subject: Re: [avr-gcc-list] long character constants like 'abcd'
Date: 22 Jan 2003 08:43:30 +0100

On Tue, 2003-01-21 at 22:16, E. Weddington wrote:
> On 21 Jan 2003 at 20:33, Matthias Ringwald wrote:

> > Or is there another way to specify such a value ?
> > 
> > (a << 24 | b << 16  .... etc fails also..)

What are you trying to do? If you want to place 4 ASCII bytes in a 32
bit word, then do:

        (('a' << 24) | ('b' << 16) | ('c' << 8) | 'd')

> u32 is a 32 bit number type. Whenever you enclose one character in 
> single quotes it is of type char. Thus 'abcd' does not even make 
> sense as a character type. 

FYI:
Traditionally (as in K&R), 'ab' was technically a legal presentation for
(('a' << 8) | 'b') or (('b' << 8) | 'a'). The actual byte sequence was
up to the compiler, which made the feature simply to esoteric. Four
character constants was also supported. 

It may have disappeared altogether in later C variants.

Egil
-- 
Email: address@hidden  
Voice/videophone: +47 22523641 Voice: +47 92022780 Fax: +47 22525899
Mail:  Egil Kvaleberg, Husebybakken 14A, 0379 Oslo, Norway
Home:  http://www.kvaleberg.com/
avr-gcc-list at http://avr1.org



reply via email to

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