Skip to content

Sizeof of standard types (from stdint.h and limits.h) for preprocessor

License

Notifications You must be signed in to change notification settings

ruslo/intsizeof

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IntSizeof

Travis AppVeyor

Sizeof of standard types (from stdint.h and limits.h) for preprocessor.

stdint.h:

  • INTSIZEOF_PTRDIFF == sizeof(ptrdiff_t)
  • INTSIZEOF_SIZE == sizeof(size_t)
  • INTSIZEOF_SIG_ATOMIC == sizeof(sig_atomic_t)
  • INTSIZEOF_WCHAR == sizeof(wchar_t)
  • INTSIZEOF_WINT == sizeof(wint_t)
  • INTSIZEOF_CHAR == sizeof(char)

limits.h (signed):

  • INTSIZEOF_SCHAR == sizeof(signed char)
  • INTSIZEOF_SHRT == sizeof(signed short)
  • INTSIZEOF_INT == sizeof(int)
  • INTSIZEOF_LONG == sizeof(long)
  • INTSIZEOF_LLONG == sizeof(long long)

limits.h (unsigned):

  • INTSIZEOF_UCHAR == sizeof(unsigned char)
  • INTSIZEOF_USHRT == sizeof(unsigned short)
  • INTSIZEOF_UINT == sizeof(unsigned int)
  • INTSIZEOF_ULONG == sizeof(unsigned long)
  • INTSIZEOF_ULLONG == sizeof(unsigned long long)

Usage

IntSizeof can be installed by Hunter package manager:

hunter_add_package(Intsizeof)
find_package(Intsizeof CONFIG REQUIRED)
add_library(boo boo.cpp)
target_link_libraries(boo PUBLIC intsizeof::intsizeof)

C++ example:

#include <intsizeof.h> // INTSIZEOF_LONG
#include <iostream> // std::cout

int main() {
#if INTSIZEOF_LONG == 4
  std::cout << "sizeof long is 4" << std::endl;
#else
  std::cout << "sizeof long is not 4" << std::endl;
#endif
  return EXIT_SUCCESS;
}

Hints

C11 draft:

About

Sizeof of standard types (from stdint.h and limits.h) for preprocessor

Resources

License

Stars

Watchers

Forks

Packages

No packages published