You are using ascii_to_hex
before declaring it, so the compiler is inferring that it has the "default" signature for a function. I forget what exactly that is, [EDIT: It is apparently
int ascii_to_hex()
-- I looked it up ], but whatever it is, it isn't
unsigned char ascii_to_hex(unsigned char* buf)
What the compiler is telling you is that what it inferred the signature of the function to be didn't match the signature it encountered later. This is lot clearer in the output from gcc:
cc program.c -o program
program.c: In function ‘main’:
program.c:11:1: warning: implicit declaration of function ‘ascii_to_hex’ [-Wimplicit-function-declaration]
11 | ascii_to_hex(str);
| ^~~~~~~~~~~~
program.c: At top level:
program.c:16:15: error: conflicting types for ‘ascii_to_hex’
16 | unsigned char ascii_to_hex(unsigned char* buf)
| ^~~~~~~~~~~~
program.c:11:1: note: previous implicit declaration of ‘ascii_to_hex’ was here
11 | ascii_to_hex(str);
| ^~~~~~~~~~~~
make: *** [<builtin>: program] Error 1
so you may want to look into using a better compiler or IDE or turning off whatever part of your development pipeline is suppressing most of the relevant information.
To fix this, you need to either move the function definition above the definition of main
, or give a prototype for the function so the compiler knows its signature at the time it's called.