Can I invoke a static function from another compilation unit by using its address? [duplicate]

StackOverflow https://stackoverflow.com/questions/14190673

  •  13-01-2022
  •  | 
  •  

Question

Possible Duplicate:
Static function access in other files

IIRC, a static function is not visible outside of own "compilation unit", which I think is a .C file.

Can I pass its address as a parameter to a function in another unit so that the second unit will later invoke the first unit's static function as a callback?

I am guessing that the "visibility" of the static function is its visibility to the linker, so that, while I cannot directly invoke a static function of unit1.c in unit2.c, I can pass its address and invoke it by address.

Can anyone confirm that? Sorry, my C is a bit rusty these days. Thanks in advance for any help.

Was it helpful?

Solution

Yes, you can call static function in that way

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top