混合使用不同版本的 Visual Studio 2002 及更高版本构建的 C 代码静态库 [英] Mixing Static Libraries of C Code built from different versions of Visual Studio 2002 and later

查看:22
本文介绍了混合使用不同版本的 Visual Studio 2002 及更高版本构建的 C 代码静态库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 Visual Studio 2002 C (v7.0) 编译器和英特尔 Fortran 9.0.018 编译器编译并链接在一起的 C 和 Fortran 例程的静态可链接库.

I have a static linkable library of C and Fortran routines compiled and linked together using the Visual Studio 2002 C (v7.0) Compiler and the Intel Fortran 9.0.018 Compiler.

我的库中的 C 代码调用并链接到 Microsoft C-RunTime (MSCRT) 2002 静态库(单线程).我相信 2002 CRT 库的实际版本号是 v7.0

The C code in my library calls and links to the Microsoft C-RunTime (MSCRT) 2002 static libraries (single-threaded). I believe the actual version number of the 2002 CRT libraries is v7.0

我将这个静态库称为vs2002if9.lib"

I will refer to this static library as "vs2002if9.lib"

我能否使用任何更高版本的 Visual Studio(2003、2005 或 2008)安全地静态链接到我的vs2002if9.lib",而不用担心调用程序在 C 运行时调用方面的行为方式?

Can I statically link to my "vs2002if9.lib" safely using any later version of Visual Studio (2003, 2005 or 2008) without any worries about how the calling program behaves regarding the C runtime calls?

或者我是否通过混合 CRT 静态库的版本来制造问题?

Or am I creating problems by mixing version of the CRT static libs?

如果我将vs2002if9.lib"提供给第 3 方软件开发人员会怎样?我对他们有什么要求?

What if I provide my "vs2002if9.lib" to 3rd party software developers? What requirements am I imposing on them?

推荐答案

过去,混合 C 运行时对我没有用.我可以看到这种工作{也许}的唯一方式是,如果您在静态链接的 C-Runtime 的边界内完全隔离堆栈/堆的使用[没有任何东西通过参数跨越边界,那么您的 vs2009if9 是什么值.lib 提供].

Mixing C runtimes hasn't worked for me in the past. The only manner in which I can see this working {maybe} is if you're completely isolating the use of the stack/heap within the boundaries of the statically linked C-Runtime [nothing crosses boundaries via parameters but then what value is your vs2009if9.lib providing].

例如,如果您要在应用程序中分配一个指针 [堆内存] 并将该指针传递给您提供的库,应该使用哪个堆管理器?正确的答案是管理指针的堆管理器,但您的库不会知道其他堆管理器.如果您的库分配内存供应用程序使用,它会变得更丑陋,并且使用提供的指针释放/删除是应用程序的责任(糟糕的设计是的,但仍然可能).同样,将使用错误的堆管理器.

As an example, if you're to be allocating a pointer [heap memory] within the application and passing this pointer to the library you provided, which heap manager should be used? The correct answer is the heap manager managing the pointer, but your library won't know about the other heap manager. It gets uglier if your library allocates memory for use by the application and it's the applications responsibility to free/delete using the provided pointer (bad design yes but still possible). Again, the wrong heap manager will be utilized.

这篇关于混合使用不同版本的 Visual Studio 2002 及更高版本构建的 C 代码静态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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