-1

I'm trying to compile a firmware for Crazyradio PA (but the issue is not specific to it), in which I added a library I needed from Nordic Semiconductor's SDK.

The library is initially meant to be compiled under Keil µVision IDE, so I naturally changed everything in the code for it to work with SDCC without too much hassle, but a simple pointer definition is making me struggling. SDCC compiler gives me this error:

syntax error: token -> 'unsigned' ; column 10

Which corresponds to this line in the code:

unsigned char * buf = (unsigned char *)pbuf;

pbuf being an unsigned char pointer passed as an argument of the function where all this code is.

I tried the following, unsuccessfully:

  • Change the data type of buf (to anything, just to see)
  • Isolate the problem by commenting out lines before and after
  • Assigning a simple value instead of (unsigned char *)pbuf

The problem remains the same (to the difference of the data type that of course changes as well). The solution may be simple, but I've come short with ideas and I'm only a trainee with little experience with SDCC so I hope you'll be indulgent.

Thanks again and please educate me on anything I did wrong ! :)

JMA
  • 1
  • 2

1 Answers1

3

Check the SDCC documentation for standards compliance - it has some quite serious deviations in all modes - in particular in section 3.1.3:

enter image description here

Your declaration follows a non-declaration within the same scope-block. Move all declarations to the top of scope-block or start a new scope-block:

memtype = *(unsigned char*)(&pbuf);

// Start scope block for buf scope...
{
    unsigned char * buf = (unsigned char *)pbuf;

    // buf accessible on this scope only
    ...

}
Clifford
  • 88,407
  • 13
  • 85
  • 165