Difference between static function and normal function in C? -


in our project, have pretty big c file of around 50k lines, written in 90's. wanted split file based on functionality. but, functions in file declared static. so, file scoped. if split file, function in file1 cannot call function in file2 , vice-versa.

but, tl feels there memory optimization using static functions. wrote sample code see if stacks different different threads. seemed was. please enlighten me difference between static function , normal 1 other file scope?

in c, while defining function, static keyword has following 2 major consequences :

  1. prevents function name being exported (i.e. function not have external linkage). thus, preventing linkage / direct calls other parts of code.

  2. as function marked private file, compiler in better position generate complete call-graph function. may result in compiler deciding automatically in-line function better performance.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -