336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
Windows 에서는 __int64 타입의 변수를 플랫폼(x86/x64)에 관계없이 printf("%I64d", val) 형태로 출력할 수 있다.
Linux 에서는 플랫폼에 영향이 없이 처리할려면 고려할 사항들이 있다.
x86에서는 long long int 가 64비트 정수이다. 그러나 x64로 넘어가면 long int 가 64비트 정수로 사용된다.
이들 문제로 인해서, 많은 혼선이 발생하고 있다.
일단 정수 타입은 다음과 같이 쓰자.
- int64_t 타입을 쓰는 걸 권장한다. 여기에는 #include <stdint.h> 가 필요하다.
- printf() 로 출력하려고 할 때, "%lld" (x86 환경), "%ld" (x64 환경) 이지만, 직접 쓰지 않는다.
빌드 플랫폼이 바뀔 때마다 이 부분에서 경고가 발생한다.
대신에 PRId64, PRIu64 를 쓰자. 여기에는 #include <inttypes.h> 가 필요하다.
#include <stdio.h> #include <stdint.h> #define __STDC_FORMAT_MACROS #include <inttypes.h> // PRId64, PRIu64 int main(int argc, char* argv[]) { int64_t val = 60000000000LL; uint64_t val2 = 90000000000000LL; printf("val: %"PRId64"\n", val); printf("val2: %"PRIu64"\n", val2); return 0; }
참고:
- http://stackoverflow.com/questions/9225567/how-to-print-a-int64-t-type-in-c
- http://stackoverflow.com/questions/8132399/how-to-printf-uint64-t
- http://stackoverflow.com/questions/2426113/i-have-having-following-warning-in-gcc-compilation-in-32-bit-architecture-but-no
- http://stackoverflow.com/questions/4160945/c-long-long-int-vs-long-int-vs-int64-t
- http://gcc.gnu.org/onlinedocs/gcc/Long-Long.html
'Programming > C / C++' 카테고리의 다른 글
C++ 텔레그램 채널 (0) | 2020.02.10 |
---|---|
How to detect programmatically whether you are running on 64-bit Windows (0) | 2015.10.01 |
to read UTF-8 XML using TinyXML (0) | 2015.08.06 |
Named Pipe Server Using Overlapped I/O and Client (0) | 2015.06.12 |
Windows Named Pipe 구현 간단 정리 (0) | 2015.06.11 |