This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: FW: Missing strtoull()...: long long standard


> 
> My guess is that long long & unsigned long long are not part of the ANSI C
> standard.  GCC is the only compiler I've seen that supports that syntax so
> I assume its a GCC extension to the C language to get 64 bits.
> It would be nice to get a standard 64 bit type.  Does any one know if this
> exists or if one has been proposed ?
> 
> Brendan Simon.
> 
> 

Yes, a standard exists, albeit it is not the official standard yet.
The ANSI C next standard is being discussed as the document:
 WG14/NT794 j11/97-158.

This document proposes long long as a type for the C language page 38.
lcc-win32 has implemented this type too as a long long, with an (automatic)
#define  __int64 long long
to remain Microsoft compatible.

As to strtoll, my system uses atoll, what should be equivalent...
It is not that complicated actually...

Here it is:
----------------------------------------------------- strtoll.c-----------
long long _strtoll(char *str)
{
        long long result = 0;
        int negative=0;

        while (*str == ' ' || *str == '\t')
                str++;
        if (*str == '+')
                str++;
        else if (*str == '-') {
                negative = 1;
                str++;
        }

        while (*str >= '0' && *str <= '9') {
                result = (result*10)+(*str++ - '0');
        }
        return negative ? -result : result;
}

-----------------------------------------------------end of strtoll.c

Unsigned versions are not that complicated either. I leave that as an exercise
to the reader :-)

-- 
Jacob Navia	Logiciels/Informatique
41 rue Maurice Ravel			Tel 01 48.23.51.44
93430 Villetaneuse 			Fax 01 48.23.95.39
France
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]