View previous topic :: View next topic |
Author |
Message |
SeeCwriter
Joined: 18 Nov 2013 Posts: 160
|
New compiler errors |
Posted: Thu Feb 04, 2016 1:02 pm |
|
|
I installed the new compiler version, v5.055, and now I'm getting the following
errors on an existing project that I didn't get with prior versions.
Code: |
void func1( char *p )
{
char *ptr, dlim[2];
dlim[0] = ';';
dlim[1] = '\0';
ptr = strtok( p, dlim );
while( ptr != NULL ) {
process_cmd( ptr );
ptr = strtok( NULL, dlim ); // <-- Pointer types do not match.
}
}
void func2( char *p )
{
int16_t val;
float fval;
// set 'val' to some value.
fval = atof( p+val ); // <-- Pointer types do not match.
}
|
This is for an 18F67K22. |
|
|
SeeCwriter
Joined: 18 Nov 2013 Posts: 160
|
|
Posted: Thu Feb 04, 2016 3:33 pm |
|
|
To remove the strtok() warning requires NULL to be cast as a char*.
But no amount of casting removes the atof() warning. I had to replace
atof() with strtof() and cast both arguments as char*.
Yet, I use atoi() with the same pointer argument as atof(), and get no
pointer warnings. ?? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 04, 2016 10:01 pm |
|
|
This line in stdlib.h is causing the pointer mismatch warning:
Code: | #define atof(s) strtof(s, 0) |
One way to fix it is to add the two lines shown in bold below to your main
source file:
Quote: | #include <18F67K22.h>
#fuses INTRC_IO, NOWDT
#use delay(clock=4M)
#use rs232(baud=9600, UART1, ERRORS)
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#undef atof
#define atof(s) strtof(s, (char *)0)
|
|
|
|
|