macro preprocessing C51 x armcc

Discussion in 'C Programming' started by entik, Mar 23, 2012.

  1. entik

    entik

    Joined:
    Mar 23, 2012
    Messages:
    2
    Likes Received:
    0
    Hello,
    I have following code and macros:

    Code (Text):

    struct tagged_class
    {
      unsigned short tag;
      char *format;
    };

    #define BEGIN_CLASS(name, tag, fmt)                      \
      struct tagged_class name##_class = { tag, fmt };      \      
      struct name {                      \
      struct tagged_class *klass;
     
    #define END_CLASS };

    BEGIN_CLASS(cstring, 101, "s")
        char* value;
    END_CLASS
     
    I have been using it quite some time with C51 compiler, no problem, it is expanded by preprocessor to

    Code (Text):

    struct tagged_class cstring_class = { 101, "s" };
    struct cstring {   
    struct tagged_class *klass;
     char* value;
    };
     
    which is correct and as I want it. However, I had to move to new architecture and this is what armcc produces from the very same piece of code

    Code (Text):

     struct name {                                             
    struct tagged_class *klass;

    struct tagged_class cstring_class = { 101, "s" }; \
        char* value;
    };
     
    The line order is wrong, name is not replaced by the first macro parameter and \ is not removed. I would be very grateful for any ideas how to fix that/make it work ;)

    Thanks
    Entik
     
    entik, Mar 23, 2012
    #1
    1. Advertisements

  2. entik

    entik

    Joined:
    Mar 23, 2012
    Messages:
    2
    Likes Received:
    0
    Ok, at the moment I saw it on the screen, I realized the error - it didn't recognized multi-line macro. From there, it was only one google away to the answer.

    A: Armcc has troubles with whitespace after line wrap character '\'. When all whitespace is removed and each macro line ends immediately after '\', it is processed well.

    Hope this post helps someone else in the future and therefore is not completely useless :)
     
    entik, Mar 23, 2012
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dead RAM
    Replies:
    20
    Views:
    1,523
    John Harrison
    Jul 14, 2004
  2. D Senthil Kumar

    macro name from macro?

    D Senthil Kumar, Sep 20, 2003, in forum: C Programming
    Replies:
    1
    Views:
    814
    Jack Klein
    Sep 21, 2003
  3. sounak

    to get macro name from macro value

    sounak, Nov 22, 2005, in forum: C Programming
    Replies:
    17
    Views:
    702
    Mark McIntyre
    Nov 22, 2005
  4. srinu.fsl@gmail.com

    Macro expansion in armcc

    srinu.fsl@gmail.com, Jul 11, 2006, in forum: C Programming
    Replies:
    2
    Views:
    675
    Keith Thompson
    Jul 11, 2006
  5. Henrik Goldman

    Recursing macro preprocessing?

    Henrik Goldman, Oct 21, 2006, in forum: C++
    Replies:
    4
    Views:
    544
    Kaz Kylheku
    Oct 22, 2006
  6. Francois Grieu
    Replies:
    6
    Views:
    508
    Ben Bacarisse
    Jan 18, 2008
  7. dhun

    Macro preprocessing

    dhun, Nov 7, 2009, in forum: C Programming
    Replies:
    1
    Views:
    453
    Andrey Vul
    Nov 7, 2009
  8. howhow.chen

    abt --enum_is_int option in armcc

    howhow.chen, Sep 17, 2012, in forum: C Programming
    Replies:
    0
    Views:
    448
    howhow.chen
    Sep 17, 2012
Loading...