From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: int being 2 or 4 bytes long Date: Sun, 01 Mar 1998 14:56:40 -0800 Organization: Alcyone Systems Lines: 28 Message-ID: <34F9E7A8.131D5B3E@alcyone.com> References: NNTP-Posting-Host: newton.alcyone.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Noam Rotem wrote: > Maybe it's trivial, but why is there a data type which its size can be > different in > different compilers? I refer to 'int'. Why can it be 2 or 4 bytes, > depending on the > implementation? What's the logic? The logic is that different compilers do things differently. In particular, the size of `int' is best left to the compiler because compilers will be able to do work in their native word size much faster than any other. So it makes sense to have `int' be this. If you have specific size requirements, use `short' or `long'. The limitations dictated by ANSI C are: 1. char must be at least 8 bits. 2. short must be at least 16 bits. 3. long must be at least 32 bits. 4. char must be no larger than short, which must be no larger than int, which must be no larger than long. -- Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com Alcyone Systems / http://www.alcyone.com/max/ San Jose, California, United States / icbm://+37.20.07/-121.53.38 \ "I've got the fever for the / flavor of a cracker" / Ice Cube