Wednesday, December 03, 2014

printf and size_t from clang using %zu

C99 added the printf format specifiers %zu, %zx, etc. for printing something of the type size_t.

This worked fine on my Macintosh last night running Mac OS X 10.10 (Yosemite).

However, on my Windows machine at work using clang 3.6.0, it just printed zu or zx. That is, until I realized that I needed to add -std=c99 to my command line. Then, it recognized %zu and %zx correctly.