public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* How to get std::strtoull (unsigned long long)?
@ 2011-11-29 10:23 Markus Selve
  2011-11-29 12:11 ` Csaba Raduly
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Selve @ 2011-11-29 10:23 UTC (permalink / raw)
  To: cygwin


Hello,

I'm trying to use std::strtoull in a C++ program, but compiling it I get:

 error: 'strtoull' is not a member of 'std'

It works, if I use strtoul ('unsigned long' versus 'unsigned long long'
above).
Cygwin uses newlib and I checked the documentation on the newlib homepage:
It provides both the 'unsigned long' and the 'unsigned long long' version.
Also cygwin/gcc allows to use 'unsigned long long' variables.  So it's not
that everything related 64 bit is not available, because I'm compiling for
a 32bit Windows.  Is there a special option I should use to get access to
more 64 bit methods?

Here is a simple test program to show the effect:

#include <cstdlib>

int main(int argc, char** argv)
{
    unsigned long long l = 0;

    l = std::strtoull("0x100", NULL, 16);

    return 0;
}


This is the call to the compiler:

$ g++ -Wall -o tt tt.cpp
tt.cpp: In function 'int main(int, char**)':
tt.cpp:7:9: error: 'strtoull' is not a member of 'std'


Here is my version of cygwin and gcc / g++:
CYGWIN_NT-5.1 XXXXXXXX 1.7.9(0.237/5/3) 2011-03-29 10:10 i686 Cygwin
g++ (GCC) 4.5.3



Mit freundlichen Grüßen / Kind regards

Markus Selve

zSeries I/O Firmware Developer
IBM Systems &Technology Group, Systems Software Development / i390 Firmware
Development
-------------------------------------------------------------------------------------------------------------------------------------------

IBM Deutschland
Schoenaicher Str. 220
71032 Boeblingen
Phone: +49-7031-16-5143
E-Mail: mselve at de.ibm.com
-------------------------------------------------------------------------------------------------------------------------------------------

IBM Deutschland Research & Development GmbH / Vorsitzender des
Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart,
HRB 243294


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to get std::strtoull (unsigned long long)?
  2011-11-29 10:23 How to get std::strtoull (unsigned long long)? Markus Selve
@ 2011-11-29 12:11 ` Csaba Raduly
  2011-11-29 14:03   ` Greg Chicares
  0 siblings, 1 reply; 3+ messages in thread
From: Csaba Raduly @ 2011-11-29 12:11 UTC (permalink / raw)
  To: cygwin, MSELVE

On Tue, Nov 29, 2011 at 11:04 AM, Markus Selve  wrote:
>
> Hello,
>
> I'm trying to use std::strtoull in a C++ program, but compiling it I get:
>
>  error: 'strtoull' is not a member of 'std'
>
> It works, if I use strtoul ('unsigned long' versus 'unsigned long long'
> above).
> Cygwin uses newlib and I checked the documentation on the newlib homepage:
> It provides both the 'unsigned long' and the 'unsigned long long' version.
> Also cygwin/gcc allows to use 'unsigned long long' variables.  So it's not
> that everything related 64 bit is not available, because I'm compiling for
> a 32bit Windows.  Is there a special option I should use to get access to
> more 64 bit methods?
>
> Here is a simple test program to show the effect:
>
> #include <cstdlib>
>
> int main(int argc, char** argv)
> {
>    unsigned long long l = 0;
>
>    l = std::strtoull("0x100", NULL, 16);
>
>    return 0;
> }
>
>
> This is the call to the compiler:
>
> $ g++ -Wall -o tt tt.cpp
> tt.cpp: In function 'int main(int, char**)':
> tt.cpp:7:9: error: 'strtoull' is not a member of 'std'
>
>
> Here is my version of cygwin and gcc / g++:
> CYGWIN_NT-5.1 XXXXXXXX 1.7.9(0.237/5/3) 2011-03-29 10:10 i686 Cygwin
> g++ (GCC) 4.5.3
>

Alas, cstdlib is missing the necessary using directive:

$ g++ -E strtoull.cpp | grep strto
# 1 "strtoull.cpp"
# 1 "strtoull.cpp"
          char * _strtok_last;
double __attribute__((__cdecl__)) strtod (const char *__n, char **__end_PTR);
double __attribute__((__cdecl__)) _strtod_r (struct _reent *,const
char *__n, char **__end_PTR);
float __attribute__((__cdecl__)) strtof (const char *__n, char **__end_PTR);
long __attribute__((__cdecl__)) strtol (const char *__n, char
**__end_PTR, int __base);
long __attribute__((__cdecl__)) _strtol_r (struct _reent *,const char
*__n, char **__end_PTR, int __base);
unsigned long __attribute__((__cdecl__)) strtoul (const char *__n,
char **__end_PTR, int __base);
unsigned long __attribute__((__cdecl__)) _strtoul_r (struct _reent
*,const char *__n, char **__end_PTR, int __base);
long long __attribute__((__cdecl__)) strtoll (const char *__n, char
**__end_PTR, int __base);
long long __attribute__((__cdecl__)) _strtoll_r (struct _reent *,
const char *__n, char **__end_PTR, int __base);
unsigned long long __attribute__((__cdecl__)) strtoull (const char
*__n, char **__end_PTR, int __base);
unsigned long long __attribute__((__cdecl__)) _strtoull_r (struct
_reent *, const char *__n, char **__end_PTR, int __base);
  using ::strtod;
  using ::strtol;
  using ::strtoul;
# 1 "strtoull.cpp" 2

So although stdlib.h defines strtoull, it is not made a member of namespace std.

-- 
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to get std::strtoull (unsigned long long)?
  2011-11-29 12:11 ` Csaba Raduly
@ 2011-11-29 14:03   ` Greg Chicares
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Chicares @ 2011-11-29 14:03 UTC (permalink / raw)
  To: cygwin

On 2011-11-29 10:22Z, Csaba Raduly wrote:
> On Tue, Nov 29, 2011 at 11:04 AM, Markus Selve  wrote:
>>
>> $ g++ -Wall -o tt tt.cpp
>> tt.cpp: In function 'int main(int, char**)':
>> tt.cpp:7:9: error: 'strtoull' is not a member of 'std'

The default C++ dialect is based on the 1998 standard, which
lacks strtoull() because that function first appeared in C99.

> Alas, cstdlib is missing the necessary using directive:
[...]
>   using ::strtod;
>   using ::strtol;
>   using ::strtoul;

Adding a using-declaration for ::strtoull would be a reasonable
extension, as long as '-std=c++98' is not specified.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-11-29 12:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-29 10:23 How to get std::strtoull (unsigned long long)? Markus Selve
2011-11-29 12:11 ` Csaba Raduly
2011-11-29 14:03   ` Greg Chicares

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).