Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!nuug!sigyn.idt.unit.no!ugle.unit.no!hanche From: hanche@imf.unit.no (Harald Hanche-Olsen) Newsgroups: comp.sys.mac.programmer Subject: Re: THINKC 4.0.2 #define is short Message-ID: Date: 14 Nov 90 12:18:20 GMT References: <2374@moscom.UUCP> Sender: news@ugle.unit.no Organization: The Norwegian Institute of Technology, Trondheim, Norway. Lines: 31 In-Reply-To: tcm@moscom.UUCP's message of 13 Nov 90 18:11:48 GMT In article <2374@moscom.UUCP> tcm@moscom.UUCP (Tom Maszerowski) writes: #define MaxAllocation (1<<16) sets MaxAllocation to 0. I believe that this is because the preprocessor assumes that MaxAllocation is an int ( 16 bits ) Nope, the preprocessor assumes no such thing. It does only textual substitution, so wherever MaxAllocation appears in the program it's as if it said (1<<16) instead. You're on the right rack, though... but the result of the shift is 0x10000, which requires a long ( 32 bits ). Exactly. To get the desired result, use (1L<<16). AND make sure the program doesn't try to stuff the result into an int... I realize that compiler implementers are free to make an int any size they want, but this is the first 68000 C compiler I've used where sizeof(int) != sizeof(long). Yes, it's a pain isn't it. However, be aware that there is nothing at all in the standard (ANSI or K&R) that says int==long, it's just that programmers are so used to this always being the case that they tend to be sloppy about it. Writing portable code just ain't easy! - Harald Hanche-Olsen Division of Mathematical Sciences The Norwegian Institute of Technology N-7034 Trondheim, NORWAY