2

I'm compiling my C code using Microchip's C18 compiler. I'm getting a warning [2054] suspicious pointer conversion in this code:

unsigned char ENC_MAADR1 = 0x65;
unsigned char ENC_ReadRegister(unsigned char address);
// ...
puts(ENC_ReadRegister(ENC_MAADR1)); // <-- warning on this line

What does this warning mean and how can I solve it?

1 Answers1

8

puts requires const char*, you are delivering unsigned char, not even a pointer.

From here:

#include <stdio.h> 

int puts(const char *s); 

The puts() function writes the string pointed to by s to standard output stream stdout and appends a newline character to the output. The string's terminating null character is not written.

Use putc(int c, FILE* stream) instead... See here for a reference.

Thank you for the annotations!!

bash.d
  • 13,029
  • 3
  • 29
  • 42
  • So what would a correct code look like? My pointers knowledge is bad. –  Apr 23 '13 at 09:17