Can I use Visual Studio 2010#39;s C++ compiler with Visual Studio 2008#39;s C++ Runtime Library?(我可以将 Visual Studio 2010 的 C++ 编译器与 Visual Studio 2008 的 C++ 运行时库一起使用吗?)
问题描述
我有一个应用程序需要在 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 的解决方案 看起来很有希望,但它不起作用:__imp__*@4
符号需要指针指向函数,而不是函数本身.不幸的是,我不知道如何让 Visual C++ 吐出一个带有这种名称生成的指针......(好吧,__declspec(naked)
结合 __stdcall
确实诀窍,但后来我不知道如何发出指针).
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汇编以下代码a> 并链接到生成的目标文件,并且很快 - exe 中没有 EncodePointer/DecodePointer 引用:
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++ 运行时库一起使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我可以将 Visual Studio 2010 的 C++ 编译器与 Visual Studio 2008 的 C++ 运行时库一起使用吗?
- Stroustrup 的 Simple_window.h 2022-01-01
- 静态初始化顺序失败 2022-01-01
- C++ 协变模板 2021-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 近似搜索的工作原理 2021-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 从python回调到c++的选项 2022-11-16