Search code examples
c++visual-studio-2008win32-process

static objects in visual studio build


I have a problem with my visual studio - 08 build. some of the static objects are not getting instantiated. its wierd, i have a couple of files which create similar static objects. some are created some are not. when i tried to break point in the file for uncreated objects, my breakpoint is disabled.

how do i make sure all static objects are created.

Thanks, Abhinay.


Solution

  • Are these files directly in your main project, or are they in a static library? When you make a static library, the linker only pulls in global variables (and calls their constructors) from object files that are somehow used.

    If you do have a static library, you'll have to make sure each of the files is used by a function called by the main program. Taking the address of some global variable in that file is one way to do this.