我可以使用Visual Studio 2010的C ++编译器与Visual Studio 2008的C ++运行库吗? [英] Can I use Visual Studio 2010's C++ compiler with Visual Studio 2008's C++ Runtime Library?
问题描述
我有一个需要在Windows 2000操作的应用程序。我也想使用Visual Studio 2010(主要是因为 auto
关键词)。但是,我有点绑定,因为我需要的应用程序能够在旧操作系统上操作,即:
I have an application that needs to operate on Windows 2000. I'd also like to use Visual Studio 2010 (mainly because of the change in the definition of the auto
keyword). However, I'm in a bit of a bind because I need the app to be able to operate on older OS's, namely:
- Windows 2000
- Windows XP RTM
- Windows XP SP1
Visual Studio 2010的运行时库取决于在Windows XP SP2中引入的 EncodePointer / DecodePointer
API。
Visual Studio 2010's runtime library depends on the EncodePointer / DecodePointer
API which was introduced in Windows XP SP2.
如果使用替代运行时库是可能的,这将破坏依赖于VS2010中添加的C ++ 0x功能的代码,如 std :: regex
?
If using the alternate runtime library is possible, will this break code that relies on C++0x features added in VS2010, like std::regex
?
推荐答案
Suma's solution looked pretty promising, but it doesn't work: the __imp__*@4
symbols need to be pointers to functions, rather than the functions themselves. Unfortunately, I don't know how to make Visual C++ spit out a pointer with that kind of name generation... (well, __declspec(naked)
combined with __stdcall
does the trick, but then I don't know how to emit a pointer).
- 时间正常,解决方案很简单 - 使用 FASM 组装以下代码并链接到生成的目标文件,并且预先编译 - 无EncodePointer / DecodePointer引用的exe:
If using an assembler at build-time is OK, the solution is pretty trivial - assemble the following code with FASM and link against the produced object file, and presto - no EncodePointer/DecodePointer references in the exe:
use32
format ms coff
section ".data" data
public __imp__DecodePointer@4
__imp__DecodePointer@4 dd dummy
public __imp__EncodePointer@4
__imp__EncodePointer@4 dd dummy
section ".text" code
dummy:
mov eax, [esp+4]
retn 4
这篇关于我可以使用Visual Studio 2010的C ++编译器与Visual Studio 2008的C ++运行库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!