CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

New compiler errors

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
SeeCwriter



Joined: 18 Nov 2013
Posts: 160

View user's profile Send private message

New compiler errors
PostPosted: Thu Feb 04, 2016 1:02 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Feb 04, 2016 3:33 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Feb 04, 2016 10:01 pm     Reply with quote

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)

Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group