본문 바로가기
Unreal/Manual

Unreal C++ Unreal int32, int64 사용

by Dev_카페인 2023. 10. 28.
반응형

[Unreal/C++] Unreal int32, int64 사용

 

언리얼은 멀티플랫폼을 지원하는 엔진이다.

타겟 플랫폼이 정해졌다면 int나 uint를 마음대로 사용해도 되겠지만,

다양한 플랫폼을 위해 개발할 예정이라면 명시적으로 정해진 크기의 자료형을 사용하는 것이 좋다.

즉, 16bit 컴퓨터, 32bit 컴퓨터, 64bit 컴퓨터가 있을 때 int나 uint의 정해진 크기가 다를 수 있으니

정해진 크기의 int8, int16, int32,,,, uint64 등을 사용하는 것이 좋다.

 

언리얼 공식 문서에서도 이식성이 좋은 코드를 다음과 같이 나열해놓았다.

  • bool for boolean values (NEVER assume the size of bool). BOOL will not compile.
  • TCHAR for a character (NEVER assume the size of TCHAR).
  • uint8 for unsigned bytes (1 byte).
  • int8 for signed bytes (1 byte).
  • uint16 for unsigned "shorts" (2 bytes).
  • int16 for signed "shorts" (2 bytes).
  • uint32 for unsigned ints (4 bytes).
  • int32 for signed ints (4 bytes).
  • uint64 for unsigned "quad words" (8 bytes).
  • int64 for signed "quad words" (8 bytes).
  • float for single precision floating point (4 bytes).
  • double for double precision floating point (8 bytes).
  • PTRINT for an integer that may hold a pointer (NEVER assume the size of PTRINT).

Use of C++'s int and unsigned int types—whose size may vary across platforms, but which is guaranteed to be at least 32 bits in width—is acceptable in code where the integer width is unimportant. Explicitly-sized types must still be used in serialized or replicated formats.

 

정수 너비가 중요치 않은 경우라면 코드에서 사용해도 괜찮습니다.

반응형