Project

General

Profile

Bug #1536

TNG uses incorrect format for size_t on 32bit

Added by Roland Schulz about 5 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Affected version - extra info:
Affected version:
Close

Description

When compiling with -m32 one gets:
../src/external/tng_io/src/lib/tng_io.c:736:30: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat=]
                sizeof(struct tng_gen_block), __FILE__, __LINE__);

(only the first of many).
These warning describe a real problem and should be fixed. Options:
  • Use PRIuPTR (assumes that uintptr_t is the same as size_t)
  • cast to 64-bit integer and then use 64-bit print (that's what we use in Gromacs) - need to hope that ptrs are never going to be 128bit
  • Define PRIuSIZE (as either %zu (non-MSDN) or %Iu (MSDN)) and use that - one can also define it as %u, %lu or %llu depending on arch - or define it as PRIuPTR with fallback

Also available in: Atom PDF