Message-ID: <374293B3.2DDB1749@cs.joensuu.fi> Date: Wed, 19 May 1999 13:34:28 +0300 From: Eugene Ageenko X-Mailer: Mozilla 4.51 [en] (Win95; I) X-Accept-Language: ru MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp,gnu.gcc.help,gnu.gcc To: djgpp AT delorie DOT com Subject: Re: Portability and size_t type related question - AGAIN References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com > The second point I had for Eugene is that we already solved his > original problem long ago as he proposed the above solution to > be added our library. Our solution, as you might have guess, > uses any type, not EXACTLY 2 bytes, but AT LEAST two bytes, > and then use routines such as: > > WriteIntegerToFile(file,value,bytes) > ReadIntegerFromFile(file,*value,bytes) > > This inputs/outputs the integer byte by byte, using the number > of bytes given the last parameter. But now nobody can get to COMMON decision what type should have variable value in above definition. I had required it to be unsigned long, to accept either short int, int, and long int. Other words all family of int (and we do nto work with negative numbers) But our programmers do mind about it. One said that int is better because the problems of pointer conversion in ReadIntegerFromFile will arise. (Formerly we had following function, which is not supported errors) int ReadIntegerFromFile (file, bytes) And it was proposed to change it to the above quoted definition. I have proposed to use following code to avoid problems (supposed that: int x;) > > > > > usinged long y; > > > > > if (ReadIntegerFromFile(f,&y,bytes)!=bytes) Exit_me(); > > > > > x = y; Could you advise me now, which type should be *value in the ReadIntegerFromFile functions as above? I need compatibility with 16-bit systems and ANSI (so please do not propose me long long int definition) Eugene