1

I have some code which "works" in VS2008 in that it will build and run and do what I expect. However I have a build error in VS2013, I've managed to reproduce it with just this code:

#include "stdafx.h"
#include <Windows.h>
#include <vector>

template < class T >
class SignatureScanner
{
public:
    SignatureScanner(const BYTE* aPattern, const char* aMask, int aExpectedMatches = 1, int aOffSetToFuncStart = 0)
    {
    }

    const std::vector<T> Funcs() const
    {
        return iFuncs;
    }
private:
    std::vector<T> iFuncs;
};

// Workaround/hack to define a thiscall function
static void __fastcall fake_this_call_func(void *thisPtr, void* not_used_hack, int aParam)
{
    printf("this [%x] param [%d]\n", thisPtr, aParam);
}

// type_traits(396): error C3865: '__thiscall' : can only be used on native member functions
int _tmain(int argc, _TCHAR* argv[])
{
    typedef void(__thiscall* myFuncPtr)(int thisPtr, int aParam);

    // I use this in some hook code to find a function and redirect it to fake_this_call_func
    // which works when it builds
    SignatureScanner< myFuncPtr > p(0, 0);

    return 0;
}

I want to know why did 2008 not have an error when 2013 does, and how should I go about resolving this error? It only needs to build for Windows XP 32-bit - so platform specific hacks are OK.

paulm
  • 5,629
  • 7
  • 47
  • 70
  • Hmya, C++11 happened in between, it added std::is_member_object_pointer. The added compiler support for the type trait is none too happy about you faking a member function pointer like that. – Hans Passant Mar 18 '14 at 15:01
  • Is there a workaround to please it? :) The MSDN docs for this error don't make any sense in the context that I've managed to create it in. – paulm Mar 18 '14 at 18:29
  • Removing __thiscall is the workaround. That's probably about as helpful as your question was in explaining why you need to do this. – Hans Passant Mar 18 '14 at 18:53
  • I'm hooking the member function of a class, I figured it didn't matter as to why. – paulm Mar 18 '14 at 19:39
  • Looks like the code in http://stackoverflow.com/questions/11048176/detouring-a-member-function-via-an-injected-dll will build - I'll try to figure it out from that – paulm Mar 23 '14 at 00:40

0 Answers0