Pointers to non-static vs static functions 
Author Message
 Pointers to non-static vs static functions

Hi,

According to the C standard, does it matter whether or not a function
is static when assigning it's address to a function pointer? For
example, I have:

void (*sqr)(const digit *, unsigned, digit *);
/* a few lines down... */
sqr = (size >= KARATSUBA_SQR_THRESHOLD) ? mp_sqr : mp_sqr_base;

where mp_sqr() is globally visible and mp_sqr_base() is a static
function in the same file as the code above. Is this kosher wrt the C
standard?

--
Farooq Mela



Mon, 27 Dec 2004 08:14:06 GMT  
 Pointers to non-static vs static functions

Quote:

> According to the C standard, does it matter whether or not a function
> is static when assigning it's address to a function pointer?

Nope.  It's fine either way.


Mon, 27 Dec 2004 08:16:46 GMT  
 Pointers to non-static vs static functions
On Thu, 11 Jul 2002 00:14:06 GMT, Farooq Mela said:

Quote:
> Hi,

> According to the C standard, does it matter whether or not a function
> is static when assigning it's address to a function pointer?

No. This is also a standard trick to make C do OO stuff.

Dave.

--
           David Neary,
     E-Mail: bolsh at gimp dot org
CV: http://www.redbrick.dcu.ie/~bolsh/CV/CV.html



Mon, 27 Dec 2004 15:41:06 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. One Problem in Calling Static function from Non static function

2. Accessing non-static functions from a static function

3. Linking Error - Static vs. Non-Static

4. Linking Static DLL vs Non Static DLL

5. Getting pointer to non-static member function from C callback function

6. Static array containing non static objects and functions

7. static functions and non static variables

8. static functions with non-static variables!

9. Static and non-Static member - Signature

10. Creating a static class from non static Framework classes

11. static versus non static returnvalues

12. Using Non-Static Callback Functions as member Functions VC5.0

 

 
Powered by phpBB® Forum Software