Torsten Schoenfeld wrote:
On Wed, 2007-10-24 at 21:49 +0100, William S Fulton wrote:

Any portable solutions for extracting the unsigned long long number?

The best effort I can provide is what's in Glib.  They do what Sisyphus
suggests: represent big numbers as strings if necessary.

#ifdef _MSC_VER
# include <stdlib.h>
#endif

#ifdef WIN32
# ifdef _MSC_VER
#  define PORTABLE_STRTOULL(str, end, base) _strtoui64 (str, end, base)
# else
#  define PORTABLE_STRTOULL(str, end, base) strtoul (str, end, base)
# endif
#else
# define PORTABLE_STRTOULL(str, end, base) strtoull (str, end, base)
#endif

guint64
SvGUInt64 (SV *sv)
{
#ifdef USE_64_BIT_ALL
        return SvUV (sv);
#else
        return PORTABLE_STRTOULL (SvPV_nolen (sv), NULL, 10);
#endif
}
Many thanks for all the postings. I think we'll just use a string in the Perl script as even this PORTABLE_STRTOULL cannot parse the value when stored in scientific notation.

William

Reply via email to