C의 int64_t을 출력하니까 자꾸 경고가 떠요
조회수 4429회
발생하는 문제 및 실행환경
int64_t를 %d
로 출력하니까 자꾸 경고가 떠서
더 큰 %lld
로도 해봤는데 똑같습니다 ㅜㅜ
lld가 제가 알고 있는 것 중에 제일 큰건데 어떻게 할까요..?
소스코드
#include <stdio.h>
#include <stdint.h>
int64_t my_int = 999999999999999999;
printf("This is my_int: %I64d\n", my_int); //이것도 경고
printf("This is my_int: %lld\n", my_int); //이것도 경고
경고 내용
warning: format ‘%I64d’ expects type ‘int’, but argument 2 has type ‘int64_t’
컴파일러 사양
~/dev/c$ cc -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5664~89/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5664)
1 답변
-
int64_t type:
#include <inttypes.h> int64_t t; printf("%" PRId64 "\n", t);
uint64_t type:
#include <inttypes.h> uint64_t t; printf("%" PRIu64 "\n", t);
PRIx64
로 쓰면 16진수로 출력합니다. 입력/출력에 따라 형식 지정자가 다를 수 있으니 더 많은 정보를 알아보시려면 이쪽 cppreference.com - Fixed width integer types을 참고해보세요.
댓글 입력