1
David Haskins 에 의해 "C in Linux"라는 책에서 C를 배우고 있었지만 문제가 있습니다. 이 코드를 컴파일하려고하면 :경고 : 다른 크기의 정수에서 포인터로 캐스트
#include <stdio.h>
#include <string.h>
int main (int argc, char *argv[], char *env[]) {
printf("Content-type:text/html\n\n<html><body bgcolor=#23abe2>\n");
char value[256] = "";
strncpy(value,(char *) getenv("QUERY_STRING"), 255);
printf("QUERY_STRING:%s<BR>\n", value);
printf("<form>\n");
printf("<input type=\"TEXT\" name=\"ITEM1\"> \n");
printf("<input type=\"TEXT\" name=\"ITEM2\"> \n");
printf("<input type=\"SUBMIT\">");
printf("</form></body></html>\n");
return 0;
}
터미널에이 경고가 표시됩니다!
chapter4_1.c: In function ‘main’:
chapter4_1.c:14:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
+1 캐스팅 숨김 오류에 대한 설명입니다. 일반적으로 캐스트가 잘못되었습니다. 이 규칙에는 몇 가지 예외가 있지만 캐스트가있는 이유를 실제로 이해하지 못하면 버그를 가릴 가능성이 있습니다. –