Can I use Visual Studio 2010's C++ compiler with Visual Studio 2008's C++ Runtime Library?

后端 未结 8 1157
走了就别回头了
走了就别回头了 2020-11-27 02:51

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

相关标签:
8条回答
  • 2020-11-27 03:22

    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).

    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
    
    0 讨论(0)
  • 2020-11-27 03:24

    As Visual Studio comes with support for MASM (see project properties -> Build Customizations...) the following translation of snemarch's code to MASM might be useful:

    .model flat
    
    .data
    __imp__EncodePointer@4 dd dummy
    __imp__DecodePointer@4 dd dummy
    EXTERNDEF __imp__EncodePointer@4 : DWORD
    EXTERNDEF __imp__DecodePointer@4 : DWORD
    
    .code
    dummy proc
    mov eax, [esp+4]
    ret 4
    dummy endp
    
    end
    

    And remember to set Linker->System->Minimum Required Version to 5.0 (default is 5.1) to run on Windows 2000.

    0 讨论(0)
提交回复
热议问题