From 6904914363496201261
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,e94695845965b249
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1992-12-10 06:59:10 PST
Newsgroups: comp.std.c++
Path: sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Re: Zero-length structures and pointer comparisons
Message-ID: <9234601.10277@mulga.cs.mu.OZ.AU>
Sender: news@cs.mu.OZ.AU
Organization: Computer Science, University of Melbourne, Australia
References: <1992Dec07.222242.18703@microsoft.com> <1992Dec8.103218.27689@lth.se> <9234423.15066@mulga.cs.mu.OZ.AU> <1992Dec10.121200.18889@ucc.su.OZ.AU>
Date: Thu, 10 Dec 1992 14:48:05 GMT
Lines: 23

maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:

>	Similarly suppose we allowed nested functions, then
>pointers to them would need a pointer to a stack frame as well
>as the function address (or instead of?). They would be totally
>different types of objects really.

Actually, nested functions can be handled quite transparently.
Gnu C handles pointers to nested functions by creating a "trampoline"
function on the stack, and using the address of the trampoline
function. When the trampoline function is called, all it does is push
the pointer to the stack frame, and then jump to original nested
function. This way, the nested function does receive a hidden stack
frame parameter, but you can use pass the address of the nested
function to any function such as qsort() that just expects a normal
function pointer, since the address which will be automatically
converted to the address of a newly-created trampoline.

-- 
Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
This .signature virus is a self-referential statement that is true - but 
you will only be able to consistently believe it if you copy it to your own
.signature file!


