[FIX] via source forge updates

Andreas Raab Andreas.Raab at gmx.de
Mon Feb 4 02:02:00 UTC 2002


Actually, trying to do this kind of meta-programming is rather pointless
too. squeakInt64 and squeakFileOffsetType are completely unrelated, a
system that has 64bit file support is not required to have intrinsic
64bit integers; it could always define a file offset like:
typedef struct {
	unsigned int lo;
	unsigned int hi;
} file_offset_t;
and vice versa; a system that has 64bit integers may not have 64bit file
support. Mixing up the two definition is just a bad idea.

Cheers,
  - Andreas


> -----Original Message-----
> From: squeak-dev-admin at lists.squeakfoundation.org 
> [mailto:squeak-dev-admin at lists.squeakfoundation.org] On 
> Behalf Of Richard A. O'Keefe
> Sent: Monday, February 04, 2002 1:51 AM
> To: squeak-dev at lists.squeakfoundation.org
> Subject: Re: [FIX] via source forge updates
> 
> 
> Tim Rowledge <tim at sumeru.stanford.edu> wrote:
> 	Meta programming of the C
> 	compiler would be nice here; can I do anything like
> 	#if sizeof(sqeakFileOffsetType) == 4
> 	#define squeakInt64 long long
> 	#else
> 	#define squeakInt64 long int
> 	#endif
> 	??
> 
> No.  Typedefs like squeakFileOffsetType are not defined until after
> preprocessing is complete.  You can't even ask for sizeof (int) in
> the preprocessor.  Nor can you reliably ask for arithmetic expressions
> wider than 32 bits to be evaluated in a C89 preprocessor.
> 
> C99 has <inttypes.h> which defines things like int64_t, and some
> C89 compilers also have this header.  (In fact all the UNIX C 
> compilers
> I use do, as does Code Warrior 5 on the Mac.)
> 
> Another approach is to use a "probe program".
> 
>     #include <stdio.h>
>     #include "squeak-base.h"
>     int main(void) {
> 	printf("#define squeakInt64 %s\n",
> 	       sizeof (squeakFileOffsetType) == 4 ? "long long" 
> : "long int");
> 	return 0;
>     }
> 
> Such a program might generate any number of typedefs & macros based on
> things fixed in an earlier phase.
> 
> 	I actually tried that with no success :-( but there 
> really must be some
> 	way to do it. A crucial point is that it must be ansi 
> spec, not ISO or
> 	'it works ok in gcc'. Why is ansi important? Ask me 
> once you've tried
> 	doing ports to minimal systems with just an ansilibrary 
> and monitor.
> 	
> ANSI C and ISO C are identical, except for badge engineering.
> (I guess you mean not relying on anything in the Technical 
> Corrigenda to
> the ISO standard.  The base document is the ANSI one 
> renumbered and minus
> the rationale.)
> 
> 





More information about the Squeak-dev mailing list