macro preprocessing C51 x armcc

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

  1. entik

    entik

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

    Code:
    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:
    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:
     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. Advertising

  2. entik

    entik

    Joined:
    Mar 23, 2012
    Messages:
    2
    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. Advertising

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. srinu.fsl@gmail.com

    Macro expansion in armcc

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

    Recursing macro preprocessing?

    Henrik Goldman, Oct 21, 2006, in forum: C++
    Replies:
    4
    Views:
    385
    Kaz Kylheku
    Oct 22, 2006
  3. Francois Grieu
    Replies:
    6
    Views:
    384
    Ben Bacarisse
    Jan 18, 2008
  4. Ed Prochak
    Replies:
    0
    Views:
    599
    Ed Prochak
    Apr 10, 2008
  5. howhow.chen

    abt --enum_is_int option in armcc

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

Share This Page