Reputation: 43518
I'm developing an embedded application on VxWorks.
I know that the static function is called only in the file where defined and the non static function is called in any file in the source project.
I'm wondering if there is a difference between static and non static function concening execution time and concerning memory
Upvotes: 10
Views: 9960
Reputation: 87396
It depends on your compiler. Static functions can theoretically be optimized better because the compiler will know all the places where they are being called. You should be able to get an assembly listing from your compiler and find out for yourself if they are more efficient.
Upvotes: 4
Reputation: 42175
There is no difference in execution times or runtime memory requirements.
Some (many?) linkers will find it easier to spot unused static functions and drop them so they might encourage smaller code size.
Upvotes: 3