63
votes

I know alot of similar questions were asked before but i couldn't find something that would fix this warning i get:

MyIntFunctions.c:19:2: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]

Occurs here:

void IntPrint (const void *key)
{
    printf("%d", *(int*)key); // line 19
    printf("\t-->\t");
}

and a similar warning:

MyStringFunctions.c:22:2: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]

void StringPrint (const void *key)
{
    printf("%s",(char*)key); //line 22
    printf("\t-->\t");
}

I really want to understand what is wrong so i won't do that again in the future.

3
Did you consider including <stdio.h> - WhozCraig
Please show us how do you include header file. - Adam Sznajder

3 Answers

94
votes

You need to include the appropriate header

#include <stdio.h>

If you're not sure which header a standard function is defined in, the function's man page will state this.

15
votes

You need to include a declaration of the printf() function.

#include <stdio.h>
3
votes

the warning or error of kind IMPLICIT DECLARATION is that the compiler is expecting a Function Declaration/Prototype..

It might either be a header file or your own function Declaration..