How does the compiler know not to call function once per static variable?

Posted by mkal on Stack Overflow See other posts from Stack Overflow or by mkal
Published on 2010-05-06T21:57:46Z Indexed on 2010/05/06 22:08 UTC
Read the original article Hit count: 180

Filed under:
|

E.g

 foo1() {
     static const char* str = foo2();

 }

 const char * foo2 () {

     ...
 }

How does the compiler makes sure it calls foo2 just once.

© Stack Overflow or respective owner

Related posts about static

Related posts about c++