I'm working on porting some code in a new project to XC8, and am having a few weird problems.
Specifically, with the ltoa "family" of functions (ltoa, ultoa, ftoa). The problem being that there seems to be an issue with the XC8 vs C18 style definitions.
In <stdlib.h> these are prototyped as follows:
extern char * itoa(char * buf, int val, int base);
extern char * utoa(char * buf, unsigned val, int base);
extern char * ltoa(long val, char * buf);
extern char * ultoa(unsigned long val, char * buf);
extern char * ltoa(char * buf, long val, int base);
extern char * ultoa(char * buf, unsigned long val, int base);
My code uses the ltoa(val,buf) calls, but could easily be changed to match the new xc8 syntax of ltoa(buf,val,base);
What appears to be happening is that <stdlib.h> is being included a couple of times - at least once with __18CXX being defined and at least once without. When it hits this section, it yelps about the inconsistent declarations, aka, throws the error:
C:\Program Files (x86)\Microchip\xc8\v1.10\include\stdlib.h:106: error: type redeclared
C:\Program Files (x86)\Microchip\xc8\v1.10\include\stdlib.h:106: error: conflicting declarations for variable "ltoa" (C:\Program Files (x86)\Microchip\xc8\v1.10\include\stdlib.h:109)
So some questions...
1) What is the intended 'native' XC8 syntax for these functions. It appears that it is ltoa(buf,val,base). Is this the same for XC16 and XC32?
2) Should __18CXX be getting defined? I guess I'm asking if this is supposedly a C18 define, and not a XC8 define. Any ideas why it's getting defined halfway through the code? I haven't found any places this is being defined in my code, but I guess there is a possibility it's buried somewhere.