multiline macro with embedded #

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hal Styli

    multiline macro with embedded #

    Hello, can someone please help with the following attempt at defining a
    macro ...

    I want to wrap the following in a macro:-

    if HEAD is defined then
    head=p;
    define HEAD
    else
    tail->next=p;
    end
    tail=p;

    Here is the attemp:-

    #define PTRS \
    #ifndef HEAD \
    head=p; \
    #define HEAD 1 \
    #else \
    tail->next=p; \
    #endif \
    tail=p;

    Predictably this comes out as: #ifndef HEAD head=p; #define HEAD 1 #else
    tail->next=p; #endif tail=p;
    I don't thisk this is compiler specific but just for the record,
    Borland BCC give me .. Illegal character '#' (0x23) in function main

    I'm hoping it is possible to accomplish what I want to do with macros.

    Thanks in advance for any help given.

    Hal.


Working...