programing

c - 경고: 함수의 암묵적 선언 'printf'

prostudy 2022. 9. 9. 09:19
반응형

c - 경고: 함수의 암묵적 선언 'printf'

이전에도 비슷한 질문을 많이 받았지만 이 경고를 해결할 수 있는 질문을 찾을 수 없었습니다.

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

다음과 같이 발생합니다.

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

및 유사한 경고:

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");
}

저는 정말 무엇이 잘못되었는지 이해하고 싶기 때문에 앞으로는 그렇게 하지 않을 것입니다.

적절한 헤더를 포함해야 합니다.

#include <stdio.h>

표준 함수가 어느 헤더에 정의되어 있는지 모르는 경우 함수의 man 페이지에 이 내용이 표시됩니다.

의 선언을 포함해야 합니다.printf()기능.

#include <stdio.h>

컴파일러가 함수 선언/프로토타입이 될 것으로 예상된다는 경고 또는 오류입니다.

헤더 파일 또는 자체 함수 선언 중 하나일 수 있습니다.

언급URL : https://stackoverflow.com/questions/14069226/c-warning-implicit-declaration-of-function-printf

반응형