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 19457
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 thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: George Marsaglia |
last post by:
The essence of a multiply-with-carry RNG is to have
declarations in the RNG proc, such as
unsigned long mwc( ){
static unsigned long x = 123456789, c = 362436;
unsigned long long t, a =...
|
by: Sushil |
last post by:
hi Gurus
I'm a newbie learning C.
I've a question, relevant code snippet is as follows :
typedef unsigned long long ulonglong;
struct foo {
unsigned dummy : 2;
unsigned n : 24;
|
by: Peter Ammon |
last post by:
When I add an unsigned long long and an int, what type do each of the
values get promoted to before the addition is performed? What is the
type of the resulting expression? What occurs if the...
|
by: Digital Puer |
last post by:
Hi, suppose I have an unsigned long long. I would like to extract
the front 'n' bits of this value and convert them into an integer.
For example, if I extract the first 3 bits, I would get an int...
|
by: luke |
last post by:
Hi everybody,
please, can someone explain me this behaviour.
I have the following piece of code:
long long ll;
unsigned int i = 2;
ll = -1 * i;
printf("%lld\n", ll);
|
by: Nicholas Zhou |
last post by:
Hi,
I was writing a testing program to test the ranges of char, short, int
and long variables on my computer, both signed and unsigned.
Everything was fine except for unsigned int and unsigned...
|
by: vadivel.ks |
last post by:
hi,
My code having unsigned long long int64_t;
like that.. compile error message is long followed by long is
illegal,
what is the reason for it?
|
by: Bart C |
last post by:
I've always had a problem knowing exactly how wide my integer variables were
in C, and the little program below has increased my confusion.
Run on 3 compilers on the same cpu (32-bit pentium),...
|
by: Tarique |
last post by:
This program was compiled on MS Visual C++ 08
/*Fibonacci Numbers*/
#include<stdio.h>
#include<limits.h>
void fibonacci(int n)
{
unsigned long long fib0 = 0; /*First Fibonacci Number*/
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
| |