On Wed, 09 Oct 2013 10:20:13 -0400 Ryan Johnson <ryan.john...@cs.utoronto.ca> wrote:
> > This is more portable: > > > > #ifdef SQLITE_64BIT_STATS > > sqlite3_snprintf(24, zRet, "%lld", p->nRow); > > #else > > sqlite3_snprintf(24, zRet, "%d", p->nRow); > > #endif > Actually, some machines define 64-bit ints as long, (Compilers, that is, not machines.) > Technically the portable way is to make sure the int is a [u]int64_t > from <inttypes.h> and then use the (awful and painful) printf > modifiers from the same header (PRIu64 et al). An easier workaround > is to define the int as size_t and then use %zd in printf... but I > think % zd is a GNU extension. The applicable section of the C11 standard is 7.19.6.1. The PRI-style modifiers do not appear in it. The z modifer does. Last I checked, though, Microsoft's implementation didn't support it. It's difficult to do portably because you have to account for every combination of standard C library and integer size, and the grammar supported by the printf implementation cannot be determined systematically at compile-time or runtime. Even testing for compiler vendor and version is an inference because, technically, it says nothing about which runtime library is being linked to. --jkl _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users