Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between static function and non static function in C

Tags:

c

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

like image 420
MOHAMED Avatar asked Sep 28 '12 15:09

MOHAMED


2 Answers

There is absolutely no performance difference. The the only thing the static keyword does on functions is given them internal linkage, which means they are only accessible in the file they are defined in.

like image 136
Jon Avatar answered Oct 08 '22 00:10

Jon


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.

like image 33
simonc Avatar answered Oct 08 '22 02:10

simonc