My thanks to all who replied. For the curious, the basic form of what
I'm trying to do is this:
#define FOO(A,B) stuff
should produce another macro:
#define BAR_A_B(C) stuff
The macros produce code in support of type-safe inter-process message
passing routines.
This is definitely a situation where it would be inappropriate to
deviate from the standard, and the workaround is simple enough:
#define FOO(A,B) stuff
#define BAR(A,B,C) more stuff
The reason this solution is less desirable is that the latter allows for
errors that the former would catch. But it's workable.
It's not really clear to me what you're trying to do. But I've used
sort of a backwards means of doing something similar. Consider the
following macros:
#define BIT(p,b) (b)
#define PORT(p,b) (PORT ## p)
#define PIN(p,b) (PIN ## p)
#define DDR(p,b) (DDR ## p)
#define MASK(b) (1 << (b))
#define Set_Port_Bit(p,b) ((p) |= MASK(b))
#define Clr_Port_Bit(p,b) ((p) &= ~MASK(b))
#define Tgl_Port_Bit(p,b) ((p) ^= MASK(b))
#define Get_Port_Bit(p,b) (((p) & MASK(b)) != 0)
#define Set_Output(io) Set_Port_Bit(PORT(io),BIT(io))
#define Reset_Output(io) Clr_Port_Bit(PORT(io),BIT(io))
#define Get_Input(io) Get_Port_Bit(PIN(io),BIT(io))
#define Tristate(io) Clr_Port_Bit(DDR(io),BIT(io))
#define Drive(io) Set_Port_Bit(DDR(io),BIT(io))
This was for an AVR microprocessor. There were for digital I/O ports,
a, B, C, and D. There were three I/O address for each digital I/O
port, PIN for reading input, PORT for writing output, and DDR (Data
Direction Register) to set each bit to be an input or an output. The
name of each register was appended with the port it referred to, e.g.,
PORTA, DDRB, PIND.
The macros above let me specify my output bits something like this
#define STATUS_LED A,7
#define SWITCH(n) D,(n+3) // switches on D3, D4, and D5
Then I could invoke the macros something like
Set_Output(STATUS_LED);
state = Get_Input(SWITCH(1));
If the hardware changes, and the status LED moved to port B, pin 3,
all I have to do is change the STATUS_LED definition to
#define STATUS_LED B,3
and everything works.
Perhaps you can adapt something like this.
Regards,
-=Dave