This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Variable mapping to address

Hello,
I use uVision IDE and arm-gcc toolchain for my lpc2129 board.I mapped the CAN standard filters to an area in memory:

#define StandardFilter[2] (*((volatile unsigned long *) 0xE0038000));

However in my main program the follwing syntax seems to be incorrect:

StandardFilter[0]  =       0x20012002;//this is line no.57
StandardFilter[1]       =       0x20032004;


because the compiler throws the following error:
CAN_RX.c(57): error: parse error before '[' token

Could someone tell me what the correct syntax is?
Thank you.

Parents Reply Children
  • Andy:You were right.Compiled using the -save-temps switch for gcc and found in the .i file that the semicolon was also added to the expansion. But what i fail to understand is isn't a semicolon after a #define required as per C conventions?

    Per:Thanks for the input

    #define StandardFilter1of2 (*((volatile unsigned long *) 0xE0038000))//NO SEMICOLON!
    #define StandardFilter2of2 (*((volatile unsigned long *) 0xE0038004))
    


    This worked

  • No.

    "as per C conventions?"

    Look again at Per's previous post: the Preprocessor is entirely independent of the 'C' language - a #define is not a 'C' statement.

    That was, in fact, exactly the point that I was making in the link that I gave; have a look again:
    www.8052.com/.../29152
    - it's standard 'C' stuff, nothing specifically to do with 8051, ARM, or Keil.

    You could, if you wanted, have:

    #define SEMICOLON ;
    

    think about it...

  • #define BEGIN {
    #define END }
    #define IF if (
    #define THEN ) {
    
    BEGIN
      IF a > 10 THEN
        ...
      END
    END
    

    A preprocessor is very powerful, which means that you must always think twice about how you use it. Too much clever use will often result in unhappy faces at a later stage of the sw lifespan.

  • Ok...I now understand.Thank you for the inputs.