c - Memory representation of differemt translations units -



c - Memory representation of differemt translations units -

how different translation units represented in memory?

for e.g.

//internallinkage.h static int var = 10; //file a.h void updatestatica(); //file a.cpp #include "internallinkage.h" void updatestatica() { var = 20; } //file b.h void updatestaticb(); //file b.cpp #include "internallinkage.h" void updatestaticb() { var = 30; } //main.cpp #include "internallinkage.h" #include "classa.h" #include "classb.h" int _tmain(int argc, _tchar* argv[]) { updatestatica(); updatestaticb(); printf("var = %d",var); }

the output here 10 know have 3 translations units each having there own re-create of static variable var. question is

how these translation units maintained in memory? do have separated sections each translation unit in memory compiler can maintain static variable 'var' each translation unit?

clearly there 3 different copies of variable 'var' in memory how compiler maintain re-create belongs translation unit?

c

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -