delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/09/12/09:20:39

From: kagel AT quasar DOT bloomberg DOT com
Date: Thu, 12 Sep 1996 08:59:05 -0400
Message-Id: <9609121259.AA04020@quasar.bloomberg.com >
To: rbachtel AT ghgcorp DOT ghgcorp DOT com
Cc: djgpp AT delorie DOT com
In-Reply-To: <517hq2$hqp@news.ghgcorp.com> (rbachtel@ghgcorp.ghgcorp.com)
Subject: Re: function pointers
Reply-To: kagel AT dg1 DOT bloomberg DOT com

   Errors-To: postmaster AT ns1
   Xref: news2.mv.net comp.os.msdos.djgpp:8521
   From: rbachtel AT ghgcorp DOT ghgcorp DOT com (Jeff)
   Newsgroups: comp.os.msdos.djgpp
   Date: 11 Sep 1996 23:25:54 GMT
   Organization: GHG Internet Services
   Lines: 20
   Nntp-Posting-Host: dialupline144.ghgcorp.com
   Mime-Version: 1.0
   X-Newsreader: WinVN 0.99.7
   Dj-Gateway: from newsgroup comp.os.msdos.djgpp
   Content-Type: Text/Plain; charset=US-ASCII
   Content-Length: 412

   I wish to create a variable, such that a function (with parameters)
   can be assigned to it.

   For example, in TurboP7.0:
   type
       ProcPTRType=procedure(x,y : integer);
   var
     p1,p2 : ProcPTRType;
   begin
     p1:=goober; (Where goober is a function)
     p1(13,14);

   I know there is a way to do this in DJGPP 2.0, can somebody just tell me 
   how?

Try this:
  typedef rettype (*ProcPTRType)(int,int); /* Substitute the actual return type
					     for rettype or void if function
					     has no return value. */
  ProcPTRType p1,p2;    /* This looks familiar! */

  p1 = goober;  /* Where goober is a function returning rettype (typedef'd
		   elsewhere. */
  p1(13,14);    /* Voila! */


-- 
Art S. Kagel, kagel AT quasar DOT bloomberg DOT com

A proverb is no proverb to you 'till life has illustrated it.  -- John Keats

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019