C语言 c - 警告:函数“printf”的隐式声明
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14069226/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
c - warning: implicit declaration of function ‘printf’
提问by Tom
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.
我真的很想知道出了什么问题,所以我以后不会再这样做了。
回答by simonc
回答by oleg_g
You need to include a declaration of the printf()function.
您需要包含printf()函数的声明。
#include <stdio.h>
回答by Raghu Srikanth Reddy
the warning or error of kind IMPLICIT DECLARATION is that the compiler is expecting a Function Declaration/Prototype..
类型 IMPLICIT DECLARATION 的警告或错误是编译器期望函数声明/原型..
It might either be a header file or your own function Declaration..
它可能是头文件或您自己的函数声明..

