c nested makros Verschachtelte Makros : a problem occurred to me.
Somebody might show me how to remove the "@".

I am writing c for a uc and I am lazy; so I want to solve easy problems whit makros, e.g. switching on a led.

I managed to do something like that:

    //Begin of c code
    #include <stdio.h>
    
    #define BIT_STD_SET(PORT, BITNUM) ((PORT) |= (1<<(BITNUM)))
    #define BIT_STD_CLE(PORT, BITNUM) ((PORT) &= ~(1<<(BITNUM)))
    #define BIT_STD_TOG(PORT, BITNUM) ((PORT) ^= (1<<(BITNUM)))

    #define LEDPORT_0 C
    #define LEDPAD_0 3 /*Blau*/

    #define LEDPORT_1 D
    #define LEDPAD_1 4 /*GelbWeis*/

    #define PO(n) LEDPORT_##n
    #define POR(n) PORT@PO(n)

    #define PA(n) LEDPAD_##n
    #define PAD(n) PA(n)

    #define LEDAN(n) BIT_STD_SET(POR(n),PAD(n))

 
    #define f(a,b) a##b
    #define g(a) #a
    #define h(a) g(a)
    int main()
    {
    printf("%s\n",h(LEDAN(0)));
    printf("%s\n",h(LEDAN(1)));
    printf("\n");
    printf("%s\n",h(LEDAN(1)));
    printf("\n");
    printf("%s\n",h(POR(0)));
    printf("%s\n",h(POR(1)));
    printf("%s\n",h(f(0,1)));
    printf("%s\n",g(f(0,1)));
    return 0;
    }
    //End of c code


    p@d:~/$ gcc ./mak.c
and got 
    p@d:~/$ ./a.out 

Answer:
    ((PORT@C) |= (1<<(3)))
    ((PORT@D) |= (1<<(4)))

    ((PORT@D) |= (1<<(4)))

    PORT@C
    PORT@D
    01
    f(0,1)

the "@" should be removed.
unfortunately, I do not know how. I have read some manuals, but I do not know how to express my self.

Thanks a lot.

@admins to mark code via 4 spaces is a bad and time consuming way


