EEVblog Electronics Community Forum

Products => Computers => Programming => Topic started by: Picuino on April 14, 2020, 10:27:50 am

Title: Rom Address with Microchip MPLABX and XC8
Post by: Picuino on April 14, 2020, 10:27:50 am
I have updated MPLABX from version 4 to version 5 maintaining the compiler XC8 with version 2.1

Before update, this code worked:

Code: (c) [Select]
#define SAF_ADDRESS              0x3F80   // Storage Area Flash address
const unsigned long PPB_CALIBRATION @ SAF_ADDRESS = 248444;

And now the compiler raise an error:
Code: [Select]
./calibration.h:11:36: error: expected ';' after top level declarator
const unsigned long PPB_CALIBRATION @ SAF_ADDRESS = 248444;
                                   ^
                                   ;

how can i make it work now?

Regards.
Title: Re: Rom Address with Microchip MPLABX and XC8
Post by: oPossum on April 14, 2020, 12:24:39 pm
Use __at(address)

Section 2.5.2.3 of MPLAB_XC8_C_Compiler_Legacy_User_Guide.pdf
Title: Re: Rom Address with Microchip MPLABX and XC8
Post by: Picuino on April 14, 2020, 01:11:04 pm
Thanks a lot.
Title: Re: Rom Address with Microchip MPLABX and XC8
Post by: 741 on November 19, 2020, 04:32:04 pm
I have spent nearly a day tracing this in a 2017 project. The @ symbol occurs in the usb framework code from around that time (in file usb_hal_pic16f1.h).

The section referred to is entitled
MIGRATION TO THE CCI

Also, the document MPLAB_XC8_C_Compiler_User_Guide_for_PIC.pdf, 50002737C-page 567 says this

(2036) use of @ is not compliant with CCI, use __at() instead (Parser)
The CCI does not permit the definition of absolute functions and objects that use the @ address construct. Instead,
place __at(address) after the identifier in the definition.
int foobar @ 0x100; // oops -- use __at(0x100) instead



But my project does not have the "Use CCI Syntax" checkbox checked... So why the error?
XC8 v2.20


Update: I found this post on the Microchip forum (https://www.microchip.com/forums/m1058706.aspx (https://www.microchip.com/forums/m1058706.aspx)), it seems the errors also relate to C99 mode being the new default (but only since XC8 v2.00).
Whole can of worms... :horse: |O

(It is interesting that C99 only now makes it to default in 2020! )