Path: utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!cica!iuvax!purdue!sawmill!mdbs!joe From: joe@mdbs.uucp (Joe Greer) Newsgroups: comp.os.msdos.programmer Subject: Re: TC++ pointers (compiler bug?) Message-ID: <1990Oct22.144928.27325@mdbs.uucp> Date: 22 Oct 90 14:49:28 GMT References: <1990Oct16.212118.6736@arcturus.uucp> Reply-To: joe@mdbs.UUCP (Joe Greer) Organization: mdbs, Inc. Lines: 31 In article <1990Oct16.212118.6736@arcturus.uucp> evil@arcturus.uucp (Wade Guthrie) writes: >I have been trying to port some stuff that I did at someone else's >computer (and had working) to my home machine w/Turbo C++. After >hours of debugging, I found a gotcha. The bit of code looked >something like: > > typedef struct MENU {...} MENU; > > main() > { > MENU *variable; > ... > function(variable); > ... > } > > void > function(MENU *variable) > { > printf("variable is at %p\n",variable); > ... > } > This looks like an instance of a fairly common 80x86 mistake. Since function wasn't declared before it was used, the compiler is going to assume that the argument expected by function() is an int and coerce accordingly. This typically causes pointers that look like 0x0000xxxx in the debugger. As a rule of thumb, make sure *every* function is declared before it is used. Joe Greer pur-ee!mdbs!joe