Visual Studio 构建中的静态对象
我的 Visual Studio - 08 版本有问题。一些静态对象没有被实例化。它很奇怪,我有几个创建类似静态对象的文件。有些是被创建的,有些则不是。当我尝试在文件中为未创建的对象断点时,我的断点被禁用。
我如何确保创建所有静态对象。
谢谢, 阿比奈。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这些文件是直接在您的主项目中,还是在静态库中?当您创建静态库时,链接器仅从以某种方式使用的目标文件中提取全局变量(并调用其构造函数)。
如果您确实有静态库,则必须确保每个文件都由主程序调用的函数使用。获取该文件中某个全局变量的地址是实现此目的的一种方法。
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.
您的项目有多个副本吗?如果这样做,请转到主项目文件夹,删除与“intellisense”相关的文件,然后重新加载项目。这应该有效。
Do you have several copies of your project? If you do, go to your main project folder, delete the file related to "intellisense", then reload the project. This should work.