https://microchipdeveloper.com/xc8:moving-to-xc8-2-0

V2.00 of the XC8 compiler is quite different to V1.## versions, various things are broken / change:

If you don’t want to implement this C99 changes

This guide is based on moving up to C99, but you can avoid having to do some of the changes if you want to use the older C90 standard.

If you want to continue using #asm, old style interrupt definitions and other C90 based C things then you can simply select C90 instead of C99: Properties > XC8 Global Options > C Standard.

Upgrading A Project From XC8 V1.## to XC8 V2.## and use C99

Change Project Settings

Project properties > Conf > Select XC8 v2.## compiler

Project properties > XC8 Global Options > C standard > C99

Project properties > XC8 Global Options > XC8 Linker > Link in C Library > C99

Include Files

Replace your device specific header file:

#include <p18f23k22.h>

With this generic file:

#include <xc.h>

This header file is typically included into each C source file you write. It is a generic header file that will include other device- and architecture-specific header files when you build your project.

ASM code

Remove these:

#asm
#endasm

Add this before and after each line of assembly

asm("        ");

An example:

		asm("GLOBAL _uc_asm_irq_temp");
		asm("GLOBAL _uc_asm_irq_temp1");
		//Reset timer for next rollover
		asm("movff	TMR0L,_uc_asm_irq_temp");			//read_current_timer_value (read low byte loads high byte)
		asm("movff	TMR0H,_uc_asm_irq_temp1");
		asm("movlw	0x6b");
		asm("addwf	_uc_asm_irq_temp,f,c");			//(1 = file register, 0 = access ram)
		asm("movlw	0xf0");
		asm("addwfc	_uc_asm_irq_temp1,f,c");			//(1 = file register, 0 = access ram)
		asm("movff	_uc_asm_irq_temp1,TMR0H");			//Store new value (high byte first)
		asm("movff	_uc_asm_irq_temp,TMR0L");
Interrupt Functions

Change the definitions in your .c and .h files from this format:

void interrupt interruptisrh (void);
void interrupt low_priority interruptisrl (void);

To this:

void __interrupt() interruptisrh (void);
void __interrupt(low_priority) interruptisrl (void);
near variables

For any variables defined as near add a double underscore in front of the near directive, so from this:

near static unsigned char uc_asm_irq_temp;		// near qualifier specifies access RAM
near static unsigned char uc_asm_irq_temp1;

To this:

__near static unsigned char uc_asm_irq_temp;		// near qualifier specifies access RAM
__near static unsigned char uc_asm_irq_temp1;
Possible errors

error: (2047) 24-bit floating point types are not supported when compiling in C99

Project properties > XC8 Global Options > XC8 Linker > Memory Model > Size of float 32bit

MPLAB Code Configurator

Seems you really have to use the graphical “MPLAB Code Configurator” instead of the old peripheral libraries – even though they can still be installed we ran into compile issues when we tried to use some.

For how to use see here

Peripheral Libraries

Seems you really have to use the graphical “MPLAB Code Configurator” instead of the old peripheral libraries – even though they can still be installed we ran into compile issues when we tried to use.

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.