Microchip XC8 Compiler Build Errors - Page 1
Forum section: electronics / general

author: mrhoola
author_rank: Newbie
timestamp: October 30, 2018, 02:58:43 am
content: User Level: NewbieCompiler: XC8IDE: MPLAB XMCU: PIC16f18324 (Mid-Range Enhanced, 8-bit)Program description:Blink an LED using Timer 0 and interrupts. The source code is in the attachments ("my code.txt")I have tried everything to get this simple code to successfully run.1. Checked the program for logical/syntax errors2. Configured the project with the correct settings, file names, and location3. Referred to the MPLAB XC8 Compiler manual to see if I set up the interrupt correctly4. Referred to another post regarding the same issue:https://www.eevblog.com/forum/microcontrollers/microchip-xc8-compiler-problems/5. Re-installed the compilerI don't know what to do, I've read everything and I can't this out. Help!!!Failure Description:Every time I build the code I always get the following errors:CLEAN SUCCESSFUL (total time: 14ms)make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-confmake: Entering directory 'C:/Users/Marco/Documents/MPLAB/FirstProject/TimerAndInterrupts.X'make -f nbproject/Makefile-default.mk dist/default/production/TimerAndInterrupts.X.production.hexmake: Entering directory 'C:/Users/Marco/Documents/MPLAB/FirstProject/TimerAndInterrupts.X'"C:\Program Files (x86)\Microchip\xc8\v2.00\bin\xc8-cc.exe" -mcpu=16F18324 -c -fno-short-double -fno-short-float -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -std=c99 -gdwarf-3 -mstack=compiled:auto:auto -o build/default/production/source.p1 source.csource.c:124:6: error: variable has incomplete type 'void'void interrupt MY_ISR(void)^source.c:124:15: error: expected ';' after top level declaratorvoid interrupt MY_ISR(void)^;2 errors generated.(908) exit status = 1nbproject/Makefile-default.mk:105: recipe for target 'build/default/production/source.p1' failedmake: *** [build/default/production/source.p1] Error 1make: Leaving directory 'C:/Users/Marco/Documents/MPLAB/FirstProject/TimerAndInterrupts.X'make: *** [.build-conf] Error 2nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failedmake: *** [.build-impl] Error 2make: Leaving directory 'C:/Users/Marco/Documents/MPLAB/FirstProject/TimerAndInterrupts.X'nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failedBUILD FAILED (exit value 2, total time: 1s)

author: oPossum
author_rank: Super Contributor
timestamp: October 30, 2018, 04:13:15 am
content: XC8 users guide page 34Code:__interrupt() void MY_ISR(void){TMR0IF = 0;LATC5 = 1 ;__delay_us(3);LATC5 = 0;}

author: mrhoola
author_rank: Newbie
timestamp: October 30, 2018, 04:38:45 am
content: Wow, it worked!My thoughts initially on the PIC16 was that you could have formatted the interrupt as stated in the first two bullets on page 201 MPLAB XC Compiler Manual since there is only one vector for the interrupt- Hence no priority scheme :5.9.1 Writing an Interrupt Service RoutineThe prototype and content of an ISR will vary based on the target device and the projectbeing compiled. Observe the following guidelines when writing an ISR.For devices that do not have the ICM module:• Write each ISR prototype using either the interrupt or__interrupt()specifiers.• Use void as the return type and for the parameter specification.• If your device supports interrupt priorities, with each function use thelow_priority or high_priority arguments to __interrupt(), or usethese as stand-alone specifiers with interrupt.That is why in my program I did it the way I did. But Thank you so much for your help, I would have never have tried this. !

author: oPossum
author_rank: Super Contributor
timestamp: October 30, 2018, 05:09:44 am
content: There are unfortunately some omissions in the manual that can cause unexpected problems.I have observed that is is necessary to set the XC8 C standard to C90 for these to work:interruptshort longitoa()Possibly others that I have not yet discovered.

author: JPortici
author_rank: Super Contributor
timestamp: October 30, 2018, 09:03:25 am
content: why are they omissions? those are non-standard keywords so to adhere to the standard they need to have a double underscoreinterrupt -> __interrupt (with the various attributes)short long, which is used for the non-standard 24 bit type, which was present in stdint.h as int24_t/uint24_t -> __int24,__uint24 (and the compiler should generate a warning when you use short long asking you to use these two types)itoa is NOT part of the standard C library so i guess it was removed, but an implementation of itoa should be trivial. maybe it will be added again in 2.05 (which is coming out... soon they say. It's been soon for a month :/)In the past they tried to remove some of the non-standard extensions such as the 24 bit type but it was enabled again in a matter of days and a patch because the custom type is also used internally for multiplication and divisionkeep on reading the fantastic manual! it was written by very competent people and there is virtually nothing that i wasn't able to figure out by just looking at the relevant chapters.XC8 is also written by very competent people and goes to extreme lenghts to be clever and work around the limitations of the architecture if you write clean and simple code.two examplesCode:unsigned c = 0x55;c = (c << 1) | (c >> 7);will be excecuted as a rotate instructionCode:uint16_t read_flash(uint16_t address) {uint16_t __rom *progmem_ptr;progmem_ptr = (uint16_t __rom *) address;return *progmem_ptr;}will generate all the code necessary to read flash memory, at any address, on any PIC18. but should work as-is on PIC16 as well. should also work out alignment on its own.just make sure yo uare reading the correct manual, you have the XC8 manual for C99 mode and the XC8 LEGACY manual for C90 mode

author: cobusve
author_rank: Newbie
timestamp: January 29, 2019, 07:14:42 am
content: This is not really an omission. With the introduction of XC8 V2.0 a major part of the compiler (the front-end) was entirely replaced. This had some good and some bad consequences. On the positive side it brought the compiler up to the C99 standard, which allows you to use things like named initializers in structures and many other nice C99 goodies, but it also means some changes to a list of things which used to work in the HiTech compiler, but were never standard and portable.There is a more complete write-up about this herehttps://www.microforum.cc/topic/5-i-used-to-use-to-locate-variables-but-since-xc8-20-this-is-no-longer-working/The short version is that there has for some time been a standards compliant way to do things (called the CCI or common compiler interface) with XC8, and the compiler remained backwards compatible with the old HiTech non-standard ways of doing things. With the major version change of the compiler some of these old non-standard things were eventually deprecated.These chages and deprecations are well documented in both the release notes and the User's Guide.