10

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

3 Answers 3

18

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.

Sign up to request clarification or add additional context in comments.

Comments

4

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.

1 Comment

are there difference concerning running performence ? and not concerning compilation and linkage?
3

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.