<p>I have some c(++) code that uses sprintf to convert a uint_64 to a string.  This needs to be portable to both linux and Solaris.</p>

<p>On linux we use %ju, but there does not appear to be any equivalent on Solaris.  The closest I can find is %lu, but this produces incorrect output.  Some sample code:</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;sys/types.h&gt;

#ifdef SunOS
typedef uint64_t u_int64_t;
#endif

int main(int argc, char **argv) {
    u_int64_t val = 123456789123L;

#ifdef SunOS
    printf("%lu\n", val);
#else
    printf("%ju\n", val);
#endif
}
</code></pre>

<p>On linux, the output is as expected; on Solaris 9 (don't ask), it's "28"</p>

<p>What can I use?</p>

You can use
```
%llu
```
for long long. However, this is not very portable either, because
```
long long
```
isn't guaranteed to be 64 bits. :-)