Date: Wed, 12 May 1999 17:07:25 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Eugene Ageenko cc: djgpp AT delorie DOT com Subject: Re: Portability and size_t type related question In-Reply-To: <373985AA.EF8D47D5@cs.joensuu.fi> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Wed, 12 May 1999, Eugene Ageenko wrote: > Q1. Is there any way in C to specify the integer type for variable and > to be sure that this type is exactly 4 bytes long. No. You need to write a small test program for that. > Like 'char' is always 1 byte. That's not true, either. There are compilers (mostly for embedded systems) where `char' is 32-bit wide. > It is because 'int' is depending on the system, and I have to be sure > I am writing/reading 4 bytes (ot let's say the SAME amount of bytes > to/from file). This is for portability. The usual way is to use a typedef, like "int_32", and have the typedef change on each supported system as necessary. > Q2. More complicated question: the type 'size_t'. Why is this a different question? The answer is the same as Q1. > Actually I wish to use some type which is of the constant length and > wanna be sure it will be portable. This isn't possible with the current C standards.