|
From: Oliver F. <ol...@gm...> - 2001-04-09 07:32:44
|
afaik, there is no guarantee for the implementation of int's K&R says: sizeof(short) <= sizeof(int) <= sizeof(long) > -----Original Message----- > From: Javier González [SMTP:xav...@ho...] > Sent: Saturday, April 07, 2001 5:58 PM > To: Lloyd Dupont; Mingw list > Subject: Re: [Mingw-users] sizeof long > > > i discover, with surprise that sizeof(long) = 4 > > is it normal ? i always believe it is 8. > > sizeof(char) = 1 byte > sizeof(short int) = 2 bytes > sizeof(int) (16 bit compilers) = 2 bytes > sizeof(int) (32 bit compilers) = 4 bytes > sizeof(long int) = 4 bytes > > the sizeof longs have been always 4 bytes :) > > _______________________________________________ > MinGW-users mailing list > Min...@li... > > You may change your MinGW Account Options at: > http://lists.sourceforge.net/lists/listinfo/mingw-users -- **************************************************** Oliver Fuchs E-Mail: ol...@gm... PGP 5.5.3i User To get the key, send a mail with Get PGP-Key in subject **************************************************** GMX - Die Kommunikationsplattform im Internet. http://www.gmx.net |
|
From: Joerg B. <jo...@sq...> - 2001-04-09 08:48:21
|
Hi !
Lloyd Dupont wrote:
>
> ok, if i well understand char, short, long have a size independant
> of thet processor
> whire are, respectively, 1, 2, 4.
> and int is the size of a register. 4 on 486 machine an even 8 on a
> 64 bits machine (so sinzeof(int) > sizeof(long) for such a machine)
I do not know the exact location(s) in the C standard(s),
but I am quite sure this is wrong:
On byte-addressable machines, "char" is 1 byte.
(AFAIK, it is even defined that on _all_ machines
sizeof ( char ) == 1 .)
On all machines, the C standard(s) require
sizeof ( short ) <= sizeof ( int ) <= sizeof ( long )
and corresponding (take "(=" to read "is a subset of" / "is contained
in")
(set of all "short" values) (= (set of all "int" values)
(= (set of all "long" values)
(the same for the "unsigned" variants).
Now these two properties would be violated by your assumption.
If sizeof(long) < sizeof(int) ever were true, you could have
"int" values which do not fit into a "long" variable, this might
break several programs IMHO.
AFAIK, typically sizeof ( short ) == 2
and (on 16- or 32-bit hardware) sizeof ( long ) == 4
on 16-bit-hardware sizeof ( int ) == 2
whereas on 32-bit-hardware sizeof ( int ) == 4
On 64-bit-hardware, there may be several cases:
a) sizeof ( int ) == 4 sizeof ( long ) == 8
if the system was designed as 64-bit from the start
(like the Alpha by Digital, now Compaq)
b) sizeof ( int ) == 4 sizeof ( long long ) == 8
(at least IBM's POWER had that new type "long long"
in the C compilers for AIX versions 4.1 and 4.2,
to overcome the 2 GB file size limit even on 32-bit HW)
sizeof ( long ) == 4 ???
if binary compatibility with older hw versions is an issue
(IBM's POWER going from 32-bit to 64-bit, same may hold for HP)
(Disclaimer: I am not sure about "long" here, please check!)
Regards,
Joerg Bruehe
--
Joerg Bruehe, SQL Datenbanksysteme GmbH, Berlin, Germany
(speaking only for himself)
mailto: jo...@sq...
|
|
From: Earnie B. <ear...@ya...> - 2001-04-09 15:39:55
|
Joerg Bruehe wrote: > > Hi ! > > Lloyd Dupont wrote: > > > > ok, if i well understand char, short, long have a size independant > > of thet processor > > whire are, respectively, 1, 2, 4. > > and int is the size of a register. 4 on 486 machine an even 8 on a > > 64 bits machine (so sinzeof(int) > sizeof(long) for such a machine) > > I do not know the exact location(s) in the C standard(s), > but I am quite sure this is wrong: > > On byte-addressable machines, "char" is 1 byte. > (AFAIK, it is even defined that on _all_ machines > sizeof ( char ) == 1 .) > What is your definition of BYTE? AIUI, the standard (which I don't have a reference to either) guarantees that `sizeof(char) == 1' but doesn't guarantee that `sizeof(char) == 8bits'. AIUI, the standard says short <= int <= long <= long long <= next generation bit pattern. Given this the bit length of short, int, long, long long, ... could all be the same length. IMO, it would be beneficial for the standard to change to using int8, int16, int32, etc. so that it was obvious as to what is meant; but, that isn't likely to happen anytime soon. Earnie. _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com |
|
From: Georg F. <fu...@is...> - 2001-04-09 16:29:26
|
You can and must look in the file >>limits.h<<. ISO C requires that implementations document the ranges of the integer types in the header file *limits.h.*" Earnie Boyd wrote: > > Joerg Bruehe wrote: > > > > Hi ! > > > > Lloyd Dupont wrote: > > > > > > ok, if i well understand char, short, long have a size independant > > > of thet processor > > > whire are, respectively, 1, 2, 4. > > > and int is the size of a register. 4 on 486 machine an even 8 on a > > > 64 bits machine (so sinzeof(int) > sizeof(long) for such a machine) > > > > I do not know the exact location(s) in the C standard(s), > > but I am quite sure this is wrong: > > > > On byte-addressable machines, "char" is 1 byte. > > (AFAIK, it is even defined that on _all_ machines > > sizeof ( char ) == 1 .) > > > > What is your definition of BYTE? > AIUI, the standard (which I don't have a reference to either) guarantees > that `sizeof(char) == 1' but doesn't guarantee that `sizeof(char) == > 8bits'. > > AIUI, the standard says short <= int <= long <= long long <= next > generation bit pattern. Given this the bit length of short, int, long, > long long, ... could all be the same length. > > IMO, it would be beneficial for the standard to change to using int8, > int16, int32, etc. so that it was obvious as to what is meant; but, that > isn't likely to happen anytime soon. > > Earnie. > > _________________________________________________________ > Do You Yahoo!? > Get your free @yahoo.com address at http://mail.yahoo.com > > _______________________________________________ > MinGW-users mailing list > Min...@li... > > You may change your MinGW Account Options at: > http://lists.sourceforge.net/lists/listinfo/mingw-users -- Georg Fusz Technische Universitaet Berlin, Germany Fon: Uni.: +49 30 314 26 884 privat: +49 30 815 30 32 Handy: +49 173 20 10 696 Homepage: http://www.cadlab.tu-berlin.de/~fusz/ |
|
From: Earnie B. <ear...@ya...> - 2001-04-09 16:53:17
|
Georg Fusz wrote: > > You can and must look in the file >>limits.h<<. > > ISO C requires that implementations document the ranges of the integer types in > the header file *limits.h.*" > There also exists a stdint.h file that may help. Earnie. _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com |
|
From: Jeff S. <js...@de...> - 2001-04-09 17:28:56
|
On Mon, 9 Apr 2001, Earnie Boyd wrote: > IMO, it would be beneficial for the standard to change to using int8, > int16, int32, etc. so that it was obvious as to what is meant; but, that > isn't likely to happen anytime soon. That would cripple machines that cannot process e.g. int16 efficiently. The C language is supposed to be an abstraction layer, though it doesn't work out that way in practice. (Ironically you could use Java, which guarantees the size of all its primitive types despite its higher level of abstraction.) But to keep this slightly relevant... anybody thought about a mingw kit for IA-64? It would take some work to adapt binutils, I assume... -- Jeff Sturm jef...@co... |
|
From: Paul G. <pga...@qw...> - 2001-04-09 22:51:53
|
Hi folks, On 9 Apr 2001, at 13:48, the Illustrious Jeff Sturm wrote: > On Mon, 9 Apr 2001, Earnie Boyd wrote: > > IMO, it would be beneficial for the standard to change to using int8, > > int16, int32, etc. so that it was obvious as to what is meant; but, > > that isn't likely to happen anytime soon. > > That would cripple machines that cannot process e.g. int16 > efficiently. The C language is supposed to be an abstraction layer, > though it doesn't work out that way in practice. (Ironically you could > use Java, which guarantees the size of all its primitive types despite > its higher level of abstraction.) > > But to keep this slightly relevant... anybody thought about a mingw kit > for IA-64? It would take some work to adapt binutils, I assume... I am thinking about it...haven't gotten to it yet (systems limitations). Seems like it would be easy enough if the people and systems were available (MS based PCs are still maxed out at 32bits) As to length, well if you pre-define a value, "byte (8bits) = 1", you can then do this: (limits.h defines char_byte as 8) #define max_byte=0xf ... #define short = sizeof(char_byte) // a word/int of size 8bits #define int16 = sizeof(char_byte*2) // a word/int of size 16bits #define int32 = sizeof(char_byte*4) // a word/int of size 32bits #define int64 = sizeof(char_byte*8) // a word/int of size 64bits Math functions would probably need to be extended to accomodate something like long long (int64), which would be 16 bytes or 128 bits. Win32api still calls 32bit functions and any 64bit calls would call the 64bit functions. Some basic (and very minimal) 64bit math definitions already exist (in Mingw). Take a look at largeint.h. Unfortunately, very few individuals have the necessary resources for purchasing a pre-tested, 64bit OS to test these sorts of things in a typical residential environment. Corporate R&D is, of course, a different situation. e.g. The PS2 can handle 128bit math. (64bit long long). The tools required to do the development tend to include the purchase of a PS2 Development Console (tens of thousands of $USD at last check -- Graphics Development Station with an appx equivalent in system resources available similar to resources available on a high-end SGI). If you don't have the development tools, you can't test 64/128 bit operations. Sure, you can develop PS2 apps on a PC (MS/Macintosh), but you can't test those apps without the PS2 development station(s). I suppose that when we have a cheap 64bit OS (ie. one that the typical user can place in their workspace at home), we can seriously consider extending Mingw to support 64bit processors. If anyone out there wants to pursue 64bit extensions for Mingw, then I say go for it. Peace, Paul G. > > -- > Jeff Sturm > jef...@co... > > > _______________________________________________ > MinGW-users mailing list > Min...@li... > > You may change your MinGW Account Options at: > http://lists.sourceforge.net/lists/listinfo/mingw-users > Nothing real can be threatened. Nothing unreal exists. |
|
From: Greg C. <chi...@mi...> - 2001-04-09 23:08:31
|
Earnie Boyd wrote: > > IMO, it would be beneficial for the standard to change to using int8, > int16, int32, etc. so that it was obvious as to what is meant; but, that > isn't likely to happen anytime soon. Until then, see http://www.boost.org/libs/integer/index.htm particularly the <cstdint.hpp> header. |
|
From: Kirk I. <ca...@ne...> - 2001-04-09 23:51:42
|
Earnie Boyd wrote: > > IMO, it would be beneficial for the standard to change to using int8, > int16, int32, etc. so that it was obvious as to what is meant; but, that > isn't likely to happen anytime soon. > > Earnie. > The Glib library implemets int types of specific sizes (gint4, gint8) , and works with both unix & windows. (Possibly other platforms too, I've only used the two) http://developer.gnome.org/doc/API/glib/glib-basic-types.html -- Sincerely, Kirk Ismay ________________________________________________________________________ The Net Idea Telecommunications Inc Support: te...@ne... 101-625 Front Street, Sales: sa...@ne... Nelson BC, V1L 4B6 Phone: 352-3512 Fax: 352-9780 Open Monday to Friday 9:30-5:30 Toll Free: 1-888-246-4222 10:00 - 4:00 on Saturdays ________________________________________________________________________ |
|
From: <dan...@ya...> - 2001-04-10 01:25:07
|
--- Earnie Boyd <ear...@ya...> wrote: > Joerg Bruehe wrote: > > > > Hi ! > > > > Lloyd Dupont wrote: > > > > > > ok, if i well understand char, short, long have a size independant > > > of thet processor > > > whire are, respectively, 1, 2, 4. > > > and int is the size of a register. 4 on 486 machine an even 8 on a > > > 64 bits machine (so sinzeof(int) > sizeof(long) for such a machine) > > > > I do not know the exact location(s) in the C standard(s), > > but I am quite sure this is wrong: > > > > On byte-addressable machines, "char" is 1 byte. > > (AFAIK, it is even defined that on _all_ machines > > sizeof ( char ) == 1 .) > > > > What is your definition of BYTE? > AIUI, the standard (which I don't have a reference to either) guarantees > that `sizeof(char) == 1' but doesn't guarantee that `sizeof(char) == > 8bits'. > > AIUI, the standard says short <= int <= long <= long long <= next > generation bit pattern. Given this the bit length of short, int, long, > long long, ... could all be the same length. > > IMO, it would be beneficial for the standard to change to using int8, > int16, int32, etc. so that it was obvious as to what is meant; but, that > isn't likely to happen anytime soon. > > Earnie. > Have a look in stdint.h, which is part of C99 standard. Danny _____________________________________________________________________________ http://movies.yahoo.com.au - Yahoo! Movies - Now showing: Dude Where's My Car, The Wedding Planner, Traffic.. |
|
From: Mike T. <mi...@br...> - 2001-04-10 02:55:03
|
Hi all. Where in the mingw headers is VARIANT defined? Cheers Mike Thomas. |
|
From: Earnie B. <ear...@ya...> - 2001-04-10 13:35:42
|
Mike Thomas wrote: > > Hi all. > > Where in the mingw headers is VARIANT defined? > In the header file oaidl.h which is part of the w32api package. Earnie. _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com |
|
From: Mike T. <mi...@br...> - 2001-04-11 02:56:44
|
Thanks. I looked twice in that file yesterday and couldn't see it! Cheers Mike Thomas ----- Original Message ----- From: Earnie Boyd <ear...@ya...> To: Mike Thomas <mi...@br...> Cc: <min...@li...> Sent: Tuesday, April 10, 2001 11:35 PM Subject: Re: [Mingw-users] Where is VARIANT defined > Mike Thomas wrote: > > > > Hi all. > > > > Where in the mingw headers is VARIANT defined? > > > > In the header file oaidl.h which is part of the w32api package. > > Earnie. > > _________________________________________________________ > Do You Yahoo!? > Get your free @yahoo.com address at http://mail.yahoo.com > |
|
From: Greg C. <chi...@mi...> - 2001-04-09 22:59:23
|
Joerg Bruehe wrote: > > sizeof ( short ) <= sizeof ( int ) <= sizeof ( long ) [and much other discussion of the size of integer types] On this page http://home.att.net/~jackklein/c/inttypes.html is a very good reference written by a smart and careful guy. |