How does function-level linking deal with variables declared at file level?

From experience (rather than quoting the standard).

From experience (rather than quoting the standard): If the initilaization has visible side effects like calls into external libraries or file I/O, the initialization will always happen. Boost::singleton_default provides an interesting solution that enforces the initialization to be done only when the object is referenced elsewhere, i.e. When all other references to the object are removed by the linker, the initialization is removed, too.

Edit: Yes. G++ optimize flags try to figure out function calls and prune away . O files resulting in linker errors.

I'm not sure if this happens only with certain optimize flags, but it does happen. A bad habit in our company is the presence of a lot of 'extern g_GlobalFunction()' definitions in different files. As their calls depended on conditional code, the .

O files were often thrown away, resulting in link errors. We fixed that with g_InitModule() and g_InitFileName() calls that are called hierarchically starting from main(). Mostly, these are empty functions just meant to dissuade g++ from discarding the .

O file.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions