[ros-dev] Re: Compiler-independence for 64-bit integral constants
Mark Weaver
mark at npsl.co.uk
Tue Oct 12 01:36:59 CEST 2004
> #ifdef __GNUC__
> #define FMT_INT64 _T("L")
> #elif defined(_MSC_VER)
> #define FMT_INT64 _T("I64")
> #else
> #error Unknown compiler for 64-bit integral constant suffix
> #endif
>
>
> "FMT" stands for "format string", I think this is a bit clearer than "DEFINE" or "MAKE".
>
>
> This are some usage examples:
>
> printf("%" FMT_INT64 "d", index); /* format 64 bit decimal integer */
>
> sprintf(buffer, "%" FMT_INT64 "x", index); /* format 64 bit hex number, lower case */
>
> sprintf(buffer, "%" FMT_INT64 "X", index); /* format 64 bit hex number, upper case */
>
These don't work when compiling for a unicode build. It's relatively
common to deal with mixed strings (e.g. smtp/pop/imap/http server/client
programs should typically deal with files using unicode for paths, but
the protocol specifies ASCII strings). I would plump for
FMT_INT64A/FMT_INT64W/FMT_INT64 to take care of this.
More information about the Ros-dev
mailing list