Can a static function be called through a function pointer in C?

Yes, you can export static functions by handing out pointers to them. This is a common means of implementing the Factory pattern in C, where you can hide the implementations of a whole bunch of functions from the modules that use them, and have a FuncPtr_t GetFunction( enum whichFunctionIWant) that hands them out to consumers. That’s how many dynamic linking implementations work.

Leave a Comment