D
dacium
What is the easiest way to use printf when you are writing portable
code for systems that have different ranges on integer types etc?
For example you might have to do:
unsigned long foo=70000; printf("%lu",foo); //on one system
unsigned int foo=70000; printf("%u",foo); //and that on another system
I wrote a wrapper around printf that adds a format character to
specify bit length data types:
port_printf("%32t %64t %16t %8t",foo,foo2 etc which gets translated to
the right type based on limits.h, but this has problems because I can
never just use a const format string, i have to copy the format string
and pass a new one to printf etc.
Are there any less painful ways?
code for systems that have different ranges on integer types etc?
For example you might have to do:
unsigned long foo=70000; printf("%lu",foo); //on one system
unsigned int foo=70000; printf("%u",foo); //and that on another system
I wrote a wrapper around printf that adds a format character to
specify bit length data types:
port_printf("%32t %64t %16t %8t",foo,foo2 etc which gets translated to
the right type based on limits.h, but this has problems because I can
never just use a const format string, i have to copy the format string
and pass a new one to printf etc.
Are there any less painful ways?