cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/30/16:07:25

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Function pointers (was ...)
Date: Wed, 30 Jul 1997 08:44:01 -0700
Organization: Alcyone Systems
Lines: 30
Message-ID: <33DF6141.7F27CBD1@alcyone.com>
References: <970721172104_818627977 AT emout11 DOT mail DOT aol DOT com> <33e1c2cf DOT 7983444 AT news DOT netvision DOT net DOT il> <33DEF568 DOT 5475 AT indy DOT net>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Chris Frolik wrote:

> I don't believe you need the '&' operator here, or the '*' operator with
> the function call.  For example, if I have a function and a function
> pointer:

You are correct.  The address-of operator is superfluous when dealing with
a function pointer; the function's identified alone acts as a function
pointer.

Additionally, explicitly dereferencing the function when you call it is a
matter of style and is not required by ANSI C.  In fact, the derefencing
is completely transparent:  you could just as easily use 

    int (*fp)(void);

    fp();
    (*fp)();
    (********************fp)();

The latter call through a function pointer is, believe it or not,
perfectly good ANSI C.

-- 
       Erik Max Francis, &tSftDotIotE / email / mailto:max AT alcyone DOT com
                     Alcyone Systems /   web / http://www.alcyone.com/max/
San Jose, California, United States /  icbm / 37 20 07 N  121 53 38 W
                                   \
   "Love is not love which alters / when it alternation finds."
                                 / William Shakespeare, _Sonnets_, 116

- Raw text -


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