[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] long character constants like 'abcd'.. 2. try
From: |
Matthias Ringwald |
Subject: |
Re: [avr-gcc-list] long character constants like 'abcd'.. 2. try |
Date: |
Wed, 22 Jan 2003 09:40:55 +0100 |
Thanks for your answers..
To clarify a bit:
What are you trying to do?
I want to use 32 bit constants that are made of 4 single characters.
For me 'abcd' represents the same value as ('a' << 24 | 'b' << 16 | 'c'
<< 8 | 'd')
Its just a bit more readable and convenient.
(those type of constants are very common on the mac. they use it for
file type, file creatures,
to enumerate stuff... etc...)
Anyway, I can compile:
#include <stdio.h>
int main()
{
long id = 'asdf';
printf("= %x" , id);
}
with my normal gcc compiler (2.95.2... ok, on my 32 bit machine..) and
the output is
= 61736466
I agree that 'abcd' is not a character, but I would say that 'abcd'
represents an 32 bit constant and that
it could be handled by the preprocessor and/or the c-compiler, so I
could use it in functions calls (or wherever).
For sure, I can create this value in a function like create_id( char a,
char b, char c, char d)
my point is just about the fact that reading/writing
foo( 'abcd' , nar)
is much easier than
foo (create_id('a','b','c','d'), bar)
Another opinion?
Matthias
avr-gcc-list at http://avr1.org