简体   繁体   中英

XC8 compiler error “no identifier in declaration”

I recently took over some C and firmware responsibilities at work, and am having trouble with what seems like a basic issue but one that I can't find the answer to. I'm not very experienced with C, but I've had many years of experience with higher level languages.

The firmware is written for a PIC18F4865 and I can't get it to compile and program correctly. It was originally written on MPLAB IDE 8 using the HI-TECH PICC18 compiler, but I moved up to MPLAB X IDE and have been having problems.

First, I was using the same HI-TECH PICC18 compiler and it appeared to program successfully, but the device was not reading correctly. I then switched to the XC8 compiler and began to get an error message during compile that I can't get around.

C:/_Sable/Firmware_C/lib\eeprom.h:10: error: no identifier in declaration
C:/_Sable/Firmware_C/lib\eeprom.h:10: error: ";" expected

The eeprom.h file is

#ifndef _EEPROM_H_
#define _EEPROM_H_

#define EE_ADDR(member) (offsetof(struct ee_map_s, (member)))

extern unsigned char eeprom_read(unsigned int); // this is line 10
extern void eeprom_write(unsigned int, unsigned char);
extern void ee_read(unsigned char, void *vp, unsigned char);
extern void ee_write(unsigned char, void *vp, unsigned char);

#endif

I looked around online and saw that this error can occur in a previous included file, and I checked that file and all appeared to be fine. I even rearranged the include order, think that the error message would change if that was the case, but the error still complains about this line.

I then thought maybe the function declaration was invalid because none of the parameters are named, so I changed line 10 to:

extern unsigned char eeprom_read(unsigned int addr)

This didn't change anything. But I did have a weird feeling that when I cleaned and built again, it was not re-compiling eeprom.h. I don't know if that happens or how to force it to recompile.

I don't know if fixing this will fix the firmware issues I'm having or if I need to go back to MPLAB IDE 8, but it is still something I'd like to fix.

Some header file is using a macro to #define eeprom_read into something else, possibly the empty string. If you use a different function name, #undef eeprom_read , or do something else to cause the header to no longer make that macro, it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM