0

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.

2
  • 2
    Does it compile successfully if you rename eeprom_read to something else, such as eeprom_read_test? If so, then something is probably #defineing eeprom_read into something else, possibly the empty string. Commented Sep 21, 2012 at 16:10
  • Yes! That was it. Some new files are being included that were defining eeprom_read and eeprom_write. If you make an answer, I'll be sure to accept it. Commented Sep 21, 2012 at 16:15

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.