[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Paste structure tokens with the preprocessor ##?
From: |
Joerg Wunsch |
Subject: |
Re: [avr-gcc-list] Paste structure tokens with the preprocessor ##? |
Date: |
Thu, 8 Nov 2007 20:23:27 +0100 (MET) |
"Bob Paddock" <address@hidden> wrote:
> Is it valid to paste structure tokens with
> the preprocessor ## operator?
That's not the purpose of that operator. It's rather intended to
allow forming completely new identifiers out of fragments, as in:
#define HD44780_PORT A
#define GLUE(a, b) a##b
#define PORT(x) GLUE(PORT, x)
#define PIN(x) GLUE(PIN, x)
#define DDR(x) GLUE(DDR, x)
#define HD44780_PORTOUT PORT(HD44780_PORT)
#define HD44780_PORTIN PIN(HD44780_PORT)
#define HD44780_DDR DDR(HD44780_PORT)
....
HD44780_DDR = 0x0f;
HD44780_PORTOUT = 42;
x = HD44780_PORTIN;
For a structure, you've already got two separated identifiers anyway.
I've got the impression that everything's most likely much simpler
than you try to make it. However, I've got a hard time following your
examples, which is partially caused by your mailer wrapping up long
lines so they become unreadable.
Can you write a complete example that is compilable (well, modulo the
error, of course)? Either use a mailer that doesn't wrap lines, or
wrap them using \<newline> when inside a macro. Alternatively, file
it as an attachment.
--
cheers, J"org .-.-. --... ...-- -.. . DL8DTL
http://www.sax.de/~joerg/ NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)