DLL和STL和静态数据(哦,我的!) [英] DLLs and STLs and static data (oh my!)

查看:141
本文介绍了DLL和STL和静态数据(哦,我的!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OK .....我已经完成了相关问题的所有阅读,以及一些MSDN文章,以及一天的Google搜索。



什么是当前的最先进的技术回答这个问题:



我使用VS 2008,C ++非托管代码。我有一个解决方案文件与相当多的DLL和相当多的EXE。只要我完全控制构建环境,使得所有的部件和部件都使用相同的标志构建,并使用相同的运行时库,没有人有一个静态链接的CRT库,我可以传递STL对象吗? / p>

似乎这应该是可以的,但根据你阅读的文章,有很多恐惧,不确定性和怀疑。



我知道在幕后产生静态数据的模板有各种各样的问题(每个DLL都会得到自己的副本,导致心痛),但是常规的旧STL呢?

解决方案

我们在我们的应用程序中成功传递了由几十个DLL组成的STL对象。为了确保其运行,我们在每个构建中运行的自动测试之一是验证所有项目的设置。如果添加新项目并配置错误,或者中断现有项目的配置,则构建失败。



我们检查的设置如下。注意并不是所有这些都会导致问题,但是我们检查它们是否一致。



#defines

  _WIN32_WINNT 
STRICT
_WIN32_IE
NDEBUG
_DEBUG
_SECURE_SCL

编译器选项

  DebugInformationFormat 
WholeProgramOptimization
RuntimeLibrary


OK..... I've done all the reading on related questions, and a few MSDN articles, and about a day's worth of googling.

What's the current "state of the art" answer to this question:

I'm using VS 2008, C++ unmanaged code. I have a solution file with quite a few DLLs and quite a few EXEs. As long as I completely control the build environment, such that all pieces and parts are built with the same flags, and use the same runtime libaries, and no one has a statically linked CRT library, am I ok to pass STL objects around?

It seems like this should be OK, but depending on which article you read, there's lots of Fear, Uncertainty, and Doubt.

I know there's all sorts of problems with templates that produce static data behind the scenes (every dll would get their own copy, leading to heartache), but what about regular old STL?

解决方案

We successfully pass STL objects around in our application which is made up from dozens of DLLs. To ensure it works one of our automated tests that runs at every build is to verify the settings for all projects. If you add a new project and misconfigure it, or break the configuration of an existing project, the build fails.

The settings we check are as follows. Note not all of these will cause issues, but we check them for consistency.

#defines

_WIN32_WINNT
STRICT
_WIN32_IE
NDEBUG
_DEBUG
_SECURE_SCL

Compiler options

DebugInformationFormat
WholeProgramOptimization
RuntimeLibrary

这篇关于DLL和STL和静态数据(哦,我的!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆