Skip to content

enc: Use proper format specifier for size_t

Newbyte requested to merge Newbyte/libcmatrix:fix-32-bit-build into main

%lu, meaning long unsigned int, works fine on 64-bit architectures as it happens to be the same size as unsigned size_t there (both are 8 bytes), but on for instance 32-bit systems, unsigned size_t is half the size, 4 bytes, and as such this format specifier is not correct. This matters because the type returned by cm_olm_get_message_index is unsigned size_t and not unsigned long int. Replace it with %zu (unsigned size_t) which should work on any architecture.

Reference: https://learn.microsoft.com/en-us/cpp/c-runtime-library/format-specification-syntax-printf-and-wprintf-functions?view=msvc-170

Merge request reports