Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!udel!rochester!rit!moscom!tcm From: tcm@moscom.UUCP (Tom Maszerowski) Newsgroups: comp.sys.mac.programmer Subject: THINKC 4.0.2 #define is short Keywords: #define preprocessor short int << Message-ID: <2374@moscom.UUCP> Date: 13 Nov 90 18:11:48 GMT Reply-To: tcm@moscom.UUCP (Tom Maszerowski) Organization: Moscom Corp., E. Rochester, NY Lines: 27 Here's a gotcha in THINK C 4.0.2 that got me. It's probably in the manual somewhere, but a cursory galnce didn't reveal it ( I couldn't find any reference to #define or the preprocessor anywhere in the index). Anyway, this is what happened: given: #define MaxAllocation (1<<16) sets MaxAllocation to 0. I believe that this is because the preprocessor assumes that MaxAllocation is an int ( 16 bits ) but the result of the shift is 0x10000, which requires a long ( 32 bits ). 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). By replacing the shift with 0x10000, MaxAllocation was defined correctly. BTW, this was in code I ported, I wouldn't use this style when it's simple to just use an explicit number. Is this in UMPG? I've ftp'd it but haven't printed anything yet. -- Tom Maszerowski tcm@moscom.com {rit,tropix,ur-valhalla}!moscom!tcm *** Note Changed uucp Address ***