🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #2782

Re: TC++ pointers (compiler bug?)

#2782
From: Joe Greer
Date: Mon, 22 Oct 1990 14:49
31 lines
1379 bytes
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
Technical Details
Message-ID: <1990Oct22.144928.27325@mdbs.uucp>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!cica!iuvax!purdue!sawmill!mdbs!joe
References: <1990Oct16.212118.6736@arcturus.uucp>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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