나는 경고를 컴파일 점점 계속하지만 난 그것을 해결하는 방법을 모른다 :'% d'이 (가) 형 'INT'의 인수를 기대하지만, 인수 2는 유형이 '긴 부호 INT'[-Wformat =]
'%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [
이 프로그램은 잘 실행하지만, 난 여전히 컴파일 경고를 얻을 :
/* Sizeof.c--Program to tell byte size of the C variable */
#include <stdio.h>
int main(void) {
printf("\nA Char is %d bytes", sizeof(char));
printf("\nAn int is %d bytes", sizeof(int));
printf("\nA short is %d bytes", sizeof(short));
printf("\nA long is %d bytes", sizeof(long));
printf("\nA long long is %d bytes\n", sizeof(long long));
printf("\nAn unsigned Char is %d bytes", sizeof(unsigned char));
printf("\nAn unsigned int is %d bytes", sizeof(unsigned int));
printf("\nAn unsigned short is %d bytes", sizeof(unsigned short));
printf("\nAn unsigned long is %d bytes", sizeof(unsigned long));
printf("\nAn unsigned long long is %d bytes\n",
sizeof(unsigned long long));
printf("\nfloat is %d bytes", sizeof(float));
printf("\nA double is %d bytes\n", sizeof(double));
printf("\nA long double is %d bytes\n", sizeof(long double));
return 0;
}
Windows의 GCC 4.8.1에서 오류가 발생합니다. "% zu을 (를) 인쇄 할 때 알 수없는 변환 유형 문자 '형식이 z'입니다. –
@CzarekTomczak 업데이트 된 답변, 아마도 관련이 있습니다. –
감사 Shafik. 불행히도 이것의 어느 것도 크로스 플랫폼이 아닙니다. Linux와 Windows에서 모두 작동하도록 code에 size_t를 (unsigned long) 변환해야합니다. Linux에서 % Iu (I Integer)를 사용할 때 "format '% u'형식의 인수가 'unsigned int'입니다."오류가 발생합니다. –