Is the unsigned long long primitive data type supported in ANSI
standard C?
I've tried using it a couple of times in standard C, but to no avail.
I'm using both MS VIsual C++ 6, as well as the gcc compiler that comes
with RedHat linux 9.
If not, what data type will yield the largest unsigned integer for me?
Thanks for your help,
Rich 29 18993
Richard A. Huebner <en*****@yahoo.com> scribbled the following: Is the unsigned long long primitive data type supported in ANSI standard C?
In C99, yes. In C90, no. Most current implementations of ANSI standard
C are still C90.
I've tried using it a couple of times in standard C, but to no avail. I'm using both MS VIsual C++ 6, as well as the gcc compiler that comes with RedHat linux 9.
If not, what data type will yield the largest unsigned integer for me?
unsigned long.
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"I wish someone we knew would die so we could leave them flowers."
- A 6-year-old girl, upon seeing flowers in a cemetery
"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:bo**********@oravannahka.helsinki.fi... I've tried using it a couple of times in standard C, but to no avail. I'm using both MS VIsual C++ 6, as well as the gcc compiler that comes with RedHat linux 9.
If not, what data type will yield the largest unsigned integer for me?
unsigned long.
Actually GCC has supported "unsigned long long" for quite some time. MSVC
supports "unsigned __int64" which is a 64-bit type..
Tom
Richard A. Huebner wrote: If not, what data type will yield the largest unsigned integer for me?
I don't know how to answer your question.
uint64_t might be useful still?
Tom St Denis <to********@iahu.ca> scribbled the following: "Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message news:bo**********@oravannahka.helsinki.fi... > I've tried using it a couple of times in standard C, but to no avail. > I'm using both MS VIsual C++ 6, as well as the gcc compiler that comes > with RedHat linux 9. > If not, what data type will yield the largest unsigned integer for me?
unsigned long.
Actually GCC has supported "unsigned long long" for quite some time. MSVC supports "unsigned __int64" which is a 64-bit type..
Yes, but hardly in ANSI standard C, or what?
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Immanuel Kant but Genghis Khan."
- The Official Graffitist's Handbook
"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:bo**********@oravannahka.helsinki.fi... Tom St Denis <to********@iahu.ca> scribbled the following: "Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message news:bo**********@oravannahka.helsinki.fi... > I've tried using it a couple of times in standard C, but to no avail. > I'm using both MS VIsual C++ 6, as well as the gcc compiler that
comes > with RedHat linux 9.
> If not, what data type will yield the largest unsigned integer for
me? unsigned long. Actually GCC has supported "unsigned long long" for quite some time.
MSVC supports "unsigned __int64" which is a 64-bit type..
Yes, but hardly in ANSI standard C, or what?
ANSI is old. I for one welcome our new ISO overlords.
Tom
Tom St Denis <to********@iahu.ca> scribbled the following: "Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message news:bo**********@oravannahka.helsinki.fi... Tom St Denis <to********@iahu.ca> scribbled the following: > "Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message > news:bo**********@oravannahka.helsinki.fi... >> > I've tried using it a couple of times in standard C, but to no avail. >> > I'm using both MS VIsual C++ 6, as well as the gcc compiler that comes >> > with RedHat linux 9. >> >> > If not, what data type will yield the largest unsigned integer for me? >> >> unsigned long. > Actually GCC has supported "unsigned long long" for quite some time. MSVC > supports "unsigned __int64" which is a 64-bit type..
Yes, but hardly in ANSI standard C, or what?
ANSI is old. I for one welcome our new ISO overlords.
I would think that the difference between the ANSI and ISO versions of
the C standard is entirely bureaucratic and has no effect on the
technical content.
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"'So called' means: 'There is a long explanation for this, but I have no
time to explain it here.'"
- JIPsoft
"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:bo**********@oravannahka.helsinki.fi... ANSI is old. I for one welcome our new ISO overlords.
I would think that the difference between the ANSI and ISO versions of the C standard is entirely bureaucratic and has no effect on the technical content.
Be that as it may "unsigned long long" is part of ISOC AFAIK.
Tom
Tom St Denis <to********@iahu.ca> scribbled the following: "Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message news:bo**********@oravannahka.helsinki.fi... > ANSI is old. I for one welcome our new ISO overlords. I would think that the difference between the ANSI and ISO versions of the C standard is entirely bureaucratic and has no effect on the technical content.
Be that as it may "unsigned long long" is part of ISOC AFAIK.
ISO C99, Tom. Not ISO C90.
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"I am looking for myself. Have you seen me somewhere?"
- Anon
"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:bo**********@oravannahka.helsinki.fi... Tom St Denis <to********@iahu.ca> scribbled the following: "Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message news:bo**********@oravannahka.helsinki.fi... > ANSI is old. I for one welcome our new ISO overlords.
I would think that the difference between the ANSI and ISO versions of the C standard is entirely bureaucratic and has no effect on the technical content.
Be that as it may "unsigned long long" is part of ISOC AFAIK.
ISO C99, Tom. Not ISO C90.
Tom assumes we're dealing with the latest not the oldest.
Otherwise crack out some K&R !
Tom
"Tom St Denis" <to********@iahu.ca> wrote in message
news:P1*****************@news04.bloor.is.net.cable .rogers.com... "Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message news:bo**********@oravannahka.helsinki.fi... ANSI is old. I for one welcome our new ISO overlords.
I would think that the difference between the ANSI and ISO versions of the C standard is entirely bureaucratic and has no effect on the technical content.
Be that as it may "unsigned long long" is part of ISOC AFAIK.
The current ANSI standard for C is identical to the current ISO
standard for C, aka C99.
P.J. Plauger
Dinkumware, Ltd. http://www.dinkumware.com
Richard A. Huebner wrote: Is the unsigned long long primitive data type supported in ANSI standard C?
I've tried using it a couple of times in standard C, but to no avail. I'm using both MS VIsual C++ 6, as well as the gcc compiler that comes with RedHat linux 9.
If not, what data type will yield the largest unsigned integer for me?
Thanks for your help,
Rich
Try this.
/*
Sizes of various things in bits..
*/
#include <stdio.h>
#include <limits.h>
int main(void) {
unsigned int a, b, c;
unsigned long long x, y, z;
c = -1;
b = 1 << (sizeof(int)*CHAR_BIT-1);
a = ~b;
z = -1;
y = 1LL << (sizeof(long long)*CHAR_BIT-1);
x = ~y;
printf("Size of void = %2lu bits\n", sizeof(void) *
CHAR_BIT);
printf("Size of char = %2lu bits\n", sizeof(char) *
CHAR_BIT);
printf("Size of short = %2lu bits\n", sizeof(short) *
CHAR_BIT);
printf("Size of int = %2lu bits\n", sizeof(int) *
CHAR_BIT);
printf("Size of long = %2lu bits\n", sizeof(long) *
CHAR_BIT);
printf("Size of long long = %2lu bits\n", sizeof(long long) *
CHAR_BIT);
printf("Size of int * = %2lu bits\n", sizeof(int *) *
CHAR_BIT);
printf("Size of char * = %2lu bits\n", sizeof(char *) *
CHAR_BIT);
printf("Size of void * = %2lu bits\n", sizeof(void *) *
CHAR_BIT);
printf("Size of float = %2lu bits\n", sizeof(float) *
CHAR_BIT);
printf("Size of double = %2lu bits\n", sizeof(double) *
CHAR_BIT);
printf("Size of long double = %2lu bits\n", sizeof(long double) *
CHAR_BIT);
printf("Max int = %11d\n", a);
printf("Min int = %11d\n", b);
printf("Max unsigned int = %11u\n", c);
printf("Max long long = %20lld\n", x);
printf("Min long long = %20lld\n", y);
printf("Max unsigned long long = %20llu\n", z);
return 0;
}
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Joe Wright wrote: Richard A. Huebner wrote: Is the unsigned long long primitive data type supported in ANSI standard C?
I've tried using it a couple of times in standard C, but to no avail. I'm using both MS VIsual C++ 6, as well as the gcc compiler that comes with RedHat linux 9.
If not, what data type will yield the largest unsigned integer for me?
Thanks for your help,
Rich
Try this. [code snipped; see up-thread]
I tried it, and the compiler said:
"foo.c", line 12: warning: integer overflow detected: op "<<"
"foo.c", line 19: cannot take sizeof void
cc: acomp failed for foo.c
--
Er*********@sun.com
Eric Sosman wrote: Joe Wright wrote: Richard A. Huebner wrote: Is the unsigned long long primitive data type supported in ANSI standard C?
I've tried using it a couple of times in standard C, but to no avail. I'm using both MS VIsual C++ 6, as well as the gcc compiler that comes with RedHat linux 9.
If not, what data type will yield the largest unsigned integer for me?
Thanks for your help,
Rich
Try this. [code snipped; see up-thread]
I tried it, and the compiler said:
"foo.c", line 12: warning: integer overflow detected: op "<<" "foo.c", line 19: cannot take sizeof void cc: acomp failed for foo.c
What was wrong? Should ..
y = 1LL << (sizeof(long long)*CHAR_BIT-1);
be
y = 1ULL << (sizeof(long long)*CHAR_BIT-1);
or something?
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Richard Heathfield wrote: Joe Wright wrote:
<snip>
printf("Size of char = %2lu bits\n", sizeof(char) * CHAR_BIT);
Apart from Eric's comments, you may find it a good idea to cast the expression sizeof(char) * CHAR_BIT to unsigned long before passing it to a variadic function such as printf.
Hmm.. size_t is unsigned long on my system. But I guess we're not
supposed to know that.
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
In <bo**********@sparta.btinternet.com> Richard Heathfield <do******@address.co.uk.invalid> writes: Joe Wright wrote:
<snip>
printf("Size of char = %2lu bits\n", sizeof(char) * CHAR_BIT);
Apart from Eric's comments, you may find it a good idea to cast the expression sizeof(char) * CHAR_BIT to unsigned long before passing it to a variadic function such as printf.
Or, more generally, to the actual type expected by the respective
conversion description.
Unless you're using a conforming C99 implementation, there is no
conversion description that is guarantee to properly handle a size_t
value. Even worse, in the case of sizeof(type) * CHAR_BIT, the type
of the expression can be either size_t or int.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
In <3F***********@earthlink.net> Joe Wright <jo********@earthlink.net> writes: Try this.
/* Sizes of various things in bits.. */ #include <stdio.h> #include <limits.h>
int main(void) { unsigned int a, b, c; unsigned long long x, y, z;
c = -1; b = 1 << (sizeof(int)*CHAR_BIT-1); a = ~b;
z = -1; y = 1LL << (sizeof(long long)*CHAR_BIT-1); x = ~y;
printf("Size of void = %2lu bits\n", sizeof(void) * CHAR_BIT); printf("Size of char = %2lu bits\n", sizeof(char) * CHAR_BIT); printf("Size of short = %2lu bits\n", sizeof(short) * CHAR_BIT); printf("Size of int = %2lu bits\n", sizeof(int) * CHAR_BIT); printf("Size of long = %2lu bits\n", sizeof(long) * CHAR_BIT); printf("Size of long long = %2lu bits\n", sizeof(long long) * CHAR_BIT); printf("Size of int * = %2lu bits\n", sizeof(int *) * CHAR_BIT); printf("Size of char * = %2lu bits\n", sizeof(char *) * CHAR_BIT); printf("Size of void * = %2lu bits\n", sizeof(void *) * CHAR_BIT); printf("Size of float = %2lu bits\n", sizeof(float) * CHAR_BIT); printf("Size of double = %2lu bits\n", sizeof(double) * CHAR_BIT); printf("Size of long double = %2lu bits\n", sizeof(long double) * CHAR_BIT); printf("Max int = %11d\n", a); printf("Min int = %11d\n", b); printf("Max unsigned int = %11u\n", c); printf("Max long long = %20lld\n", x); printf("Min long long = %20lld\n", y); printf("Max unsigned long long = %20llu\n", z); return 0; }
Try it yourself, with the compiler in conforming mode, this time!
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
In <z4*****************@news04.bloor.is.net.cable.rog ers.com> "Tom St Denis" <to********@iahu.ca> writes: "Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message news:bo**********@oravannahka.helsinki.fi... Tom St Denis <to********@iahu.ca> scribbled the following: > "Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message > news:bo**********@oravannahka.helsinki.fi... >> > ANSI is old. I for one welcome our new ISO overlords. >> >> I would think that the difference between the ANSI and ISO versions of >> the C standard is entirely bureaucratic and has no effect on the >> technical content.
> Be that as it may "unsigned long long" is part of ISOC AFAIK.
ISO C99, Tom. Not ISO C90.
Tom assumes we're dealing with the latest not the oldest.
An excellent illustration of the point I've made in another thread.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
In <3F***********@earthlink.net> Joe Wright <jo********@earthlink.net> writes: Richard Heathfield wrote: Joe Wright wrote:
<snip>
> printf("Size of char = %2lu bits\n", sizeof(char) * > CHAR_BIT);
Apart from Eric's comments, you may find it a good idea to cast the expression sizeof(char) * CHAR_BIT to unsigned long before passing it to a variadic function such as printf.
Hmm.. size_t is unsigned long on my system. But I guess we're not supposed to know that.
Even if you know that, do you also know what is size_t on the systems of
the people trying to use your program?
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
"Dan Pop" <Da*****@cern.ch> wrote in message
news:bo**********@sunnews.cern.ch... In <z4*****************@news04.bloor.is.net.cable.rog ers.com> "Tom St
Denis" <to********@iahu.ca> writes:
"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message news:bo**********@oravannahka.helsinki.fi... Tom St Denis <to********@iahu.ca> scribbled the following: > "Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message > news:bo**********@oravannahka.helsinki.fi... >> > ANSI is old. I for one welcome our new ISO overlords. >> >> I would think that the difference between the ANSI and ISO versions
of >> the C standard is entirely bureaucratic and has no effect on the >> technical content.
> Be that as it may "unsigned long long" is part of ISOC AFAIK.
ISO C99, Tom. Not ISO C90.
Tom assumes we're dealing with the latest not the oldest.
An excellent illustration of the point I've made in another thread.
Tom von Tom has ways of making you talk!
Tom
Get your Server or Homepage now
Choose which one you prefer.
Redhat, Debian, FreeBSD, Mandrake, Windows, SUSE http://www.comserver.net
Jonathan2s6 <jo*********@aol.com> scribbled the following: Get your Server or Homepage now
Choose which one you prefer. Redhat, Debian, FreeBSD, Mandrake, Windows, SUSE
Get lost.
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"A bee could, in effect, gather its junk. Llamas (no poor quadripeds) tune
and vow excitedly zooming."
- JIPsoft
Dan Pop wrote: In <3F***********@earthlink.net> Joe Wright <jo********@earthlink.net> writes:
Try this.
/* Sizes of various things in bits.. */ #include <stdio.h> #include <limits.h>
int main(void) { unsigned int a, b, c; unsigned long long x, y, z;
c = -1; b = 1 << (sizeof(int)*CHAR_BIT-1); a = ~b;
z = -1; y = 1LL << (sizeof(long long)*CHAR_BIT-1); x = ~y;
printf("Size of void = %2lu bits\n", sizeof(void) * CHAR_BIT); printf("Size of char = %2lu bits\n", sizeof(char) * CHAR_BIT); printf("Size of short = %2lu bits\n", sizeof(short) * CHAR_BIT); printf("Size of int = %2lu bits\n", sizeof(int) * CHAR_BIT); printf("Size of long = %2lu bits\n", sizeof(long) * CHAR_BIT); printf("Size of long long = %2lu bits\n", sizeof(long long) * CHAR_BIT); printf("Size of int * = %2lu bits\n", sizeof(int *) * CHAR_BIT); printf("Size of char * = %2lu bits\n", sizeof(char *) * CHAR_BIT); printf("Size of void * = %2lu bits\n", sizeof(void *) * CHAR_BIT); printf("Size of float = %2lu bits\n", sizeof(float) * CHAR_BIT); printf("Size of double = %2lu bits\n", sizeof(double) * CHAR_BIT); printf("Size of long double = %2lu bits\n", sizeof(long double) * CHAR_BIT); printf("Max int = %11d\n", a); printf("Min int = %11d\n", b); printf("Max unsigned int = %11u\n", c); printf("Max long long = %20lld\n", x); printf("Min long long = %20lld\n", y); printf("Max unsigned long long = %20llu\n", z); return 0; }
Try it yourself, with the compiler in conforming mode, this time!
Come on Dan, lighten up. As you have noted elsethread, we are not likely
to have C99 conformance. Vanilla gcc compiles this fine. With -ansi
-pedantic it complains about 'long long' of course. I've already
forgotten why I felt compelled to post code here.
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein --- Da*****@cern.ch (Dan Pop) wrote in message news:<bo**********@sunnews.cern.ch>... In <bo**********@sparta.btinternet.com> Richard Heathfield <do******@address.co.uk.invalid> writes: <snip> Apart from Eric's comments, you may find it a good idea to cast the expression sizeof(char) * CHAR_BIT to unsigned long before passing it to a variadic function such as printf.
Or, more generally, to the actual type expected by the respective conversion description.
Unless you're using a conforming C99 implementation, there is no conversion description that is guarantee to properly handle a size_t value. Even worse, in the case of sizeof(type) * CHAR_BIT, the type of the expression can be either size_t or int.
....or unsigned int.
--
Peter
In <63**************************@posting.google.com > ai***@acay.com.au (Peter Nilsson) writes: Da*****@cern.ch (Dan Pop) wrote in message news:<bo**********@sunnews.cern.ch>... In <bo**********@sparta.btinternet.com> Richard Heathfield <do******@address.co.uk.invalid> writes: > <snip> >Apart from Eric's comments, you may find it a good idea to cast the >expression sizeof(char) * CHAR_BIT to unsigned long before passing it to a >variadic function such as printf.
Or, more generally, to the actual type expected by the respective conversion description.
Unless you're using a conforming C99 implementation, there is no conversion description that is guarantee to properly handle a size_t value. Even worse, in the case of sizeof(type) * CHAR_BIT, the type of the expression can be either size_t or int.
...or unsigned int.
ONLY if size_t is an alias of unsigned int (or a shorter unsigned type
with identical properties).
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
In <3F***********@earthlink.net> Joe Wright <jo********@earthlink.net> writes: Dan Pop wrote: In <3F***********@earthlink.net> Joe Wright <jo********@earthlink.net> writes:
>Try this. > >/* > Sizes of various things in bits.. >*/ >#include <stdio.h> >#include <limits.h> > >int main(void) { > unsigned int a, b, c; > unsigned long long x, y, z; > > c = -1; > b = 1 << (sizeof(int)*CHAR_BIT-1); > a = ~b; > > z = -1; > y = 1LL << (sizeof(long long)*CHAR_BIT-1); > x = ~y; > > printf("Size of void = %2lu bits\n", sizeof(void) * >CHAR_BIT); > printf("Size of char = %2lu bits\n", sizeof(char) * >CHAR_BIT); > printf("Size of short = %2lu bits\n", sizeof(short) * >CHAR_BIT); > printf("Size of int = %2lu bits\n", sizeof(int) * >CHAR_BIT); > printf("Size of long = %2lu bits\n", sizeof(long) * >CHAR_BIT); > printf("Size of long long = %2lu bits\n", sizeof(long long) * >CHAR_BIT); > printf("Size of int * = %2lu bits\n", sizeof(int *) * >CHAR_BIT); > printf("Size of char * = %2lu bits\n", sizeof(char *) * >CHAR_BIT); > printf("Size of void * = %2lu bits\n", sizeof(void *) * >CHAR_BIT); > printf("Size of float = %2lu bits\n", sizeof(float) * >CHAR_BIT); > printf("Size of double = %2lu bits\n", sizeof(double) * >CHAR_BIT); > printf("Size of long double = %2lu bits\n", sizeof(long double) * >CHAR_BIT); > printf("Max int = %11d\n", a); > printf("Min int = %11d\n", b); > printf("Max unsigned int = %11u\n", c); > printf("Max long long = %20lld\n", x); > printf("Min long long = %20lld\n", y); > printf("Max unsigned long long = %20llu\n", z); > return 0; >} Try it yourself, with the compiler in conforming mode, this time! Come on Dan, lighten up. As you have noted elsethread, we are not likely to have C99 conformance. Vanilla gcc compiles this fine.
Vanilla gcc doesn't compile C, and this is NOT a gratuitously pedantic
remark.
With -ansi -pedantic it complains about 'long long' of course. I've already forgotten why I felt compelled to post code here.
Even with -std=c99 -pedantic your code fails to compile cleanly, because
of sizeof(void) which is nonsense in C: void is an incomplete type.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de Da*****@cern.ch (Dan Pop) wrote in message news:<bp***********@sunnews.cern.ch>... In <63**************************@posting.google.com > ai***@acay.com.au (Peter Nilsson) writes:Da*****@cern.ch (Dan Pop) wrote in message news:<bo**********@sunnews.cern.ch>... In <bo**********@sparta.btinternet.com> Richard Heathfield <do******@address.co.uk.invalid> writes: > <snip> >Apart from Eric's comments, you may find it a good idea to cast the >expression sizeof(char) * CHAR_BIT to unsigned long before passing it to a >variadic function such as printf.
Or, more generally, to the actual type expected by the respective conversion description.
Unless you're using a conforming C99 implementation, there is no conversion description that is guarantee to properly handle a size_t value. Even worse, in the case of sizeof(type) * CHAR_BIT, the type of the expression can be either size_t or int.
...or unsigned int.
ONLY if size_t is an alias of unsigned int (or a shorter unsigned type with identical properties).
What properties would need to be identical?
--
Peter
Dan Pop wrote: In <3F***********@earthlink.net> Joe Wright <jo********@earthlink.net> writes:
Dan Pop wrote: In <3F***********@earthlink.net> Joe Wright <jo********@earthlink.net> writes:
>Try this. >
[ code snipped ] Try it yourself, with the compiler in conforming mode, this time!
Come on Dan, lighten up. As you have noted elsethread, we are not likely to have C99 conformance. Vanilla gcc compiles this fine.
Vanilla gcc doesn't compile C, and this is NOT a gratuitously pedantic remark.
With -ansi -pedantic it complains about 'long long' of course. I've already forgotten why I felt compelled to post code here.
Even with -std=c99 -pedantic your code fails to compile cleanly, because of sizeof(void) which is nonsense in C: void is an incomplete type.
You are completely right. I shouldn't ask you to lighten up on me. I
made at least four 'mistakes' in that code and you came down hard on two
of them. Thank you. I need to be more careful in what I write and what I
post.
I promise to be more careful in the future. Please keep trying to catch
me out.
Thanks.
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
In <63**************************@posting.google.com > ai***@acay.com.au (Peter Nilsson) writes: Da*****@cern.ch (Dan Pop) wrote in message news:<bp***********@sunnews.cern.ch>... In <63**************************@posting.google.com > ai***@acay.com.au (Peter Nilsson) writes: >Da*****@cern.ch (Dan Pop) wrote in message news:<bo**********@sunnews.cern.ch>... >> In <bo**********@sparta.btinternet.com> Richard Heathfield <do******@address.co.uk.invalid> writes: >> > <snip> >> >Apart from Eric's comments, you may find it a good idea to cast the >> >expression sizeof(char) * CHAR_BIT to unsigned long before passing it to a >> >variadic function such as printf. >> >> Or, more generally, to the actual type expected by the respective >> conversion description. >> >> Unless you're using a conforming C99 implementation, there is no >> conversion description that is guarantee to properly handle a size_t >> value. Even worse, in the case of sizeof(type) * CHAR_BIT, the type >> of the expression can be either size_t or int. > >...or unsigned int.
ONLY if size_t is an alias of unsigned int (or a shorter unsigned type with identical properties).
What properties would need to be identical?
The range.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de This discussion thread is closed Replies have been disabled for this discussion. Similar topics
1 post
views
Thread by George Marsaglia |
last post: by
|
1 post
views
Thread by Sushil |
last post: by
|
12 posts
views
Thread by Peter Ammon |
last post: by
|
36 posts
views
Thread by Digital Puer |
last post: by
|
9 posts
views
Thread by luke |
last post: by
|
3 posts
views
Thread by Nicholas Zhou |
last post: by
|
9 posts
views
Thread by vadivel.ks |
last post: by
|
21 posts
views
Thread by Bart C |
last post: by
|
17 posts
views
Thread by Tarique |
last post: by
| | | | | | | | | | |