CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2007
    Posts
    28

    _CrtSetReportHook problem

    I have created my own memory management class which basically detects where there are memory leaks in the program. To improve this further i wanted to create my own report hook, so ive constructed the function, just like told on the msdn:
    int YourReportHook( int reportType, char *message, int *returnValue );

    and ive called the set hook method
    _CrtSetReportHook(YoutReportHook)

    and when compiling i get this error :
    error C2664: '_CrtSetReportHook' : cannot convert parameter 1 from 'int (int,char *,int *)' to 'int (__cdecl *)(int,char *,int *)'
    None of the functions with this name in scope match the target type

    ive just followed what was on the msdn and this wont compile! any ideas?

  2. #2
    Join Date
    Feb 2002
    Posts
    4,640

    Re: _CrtSetReportHook problem

    Sounds like you're compiling your code as C++. Try adding:
    Code:
    extern "C" int YourReportHook( int reportType, char *message, int *returnValue );
    Viggy

  3. #3
    Join Date
    Jan 2007
    Posts
    28

    Re: _CrtSetReportHook problem

    This made no difference either. Is it impossible to use these hooks if your creating a method that is a member function?

  4. #4
    Join Date
    Feb 2002
    Posts
    4,640

    Re: _CrtSetReportHook problem

    Oh, well, see, you didn't say that in your original post!

    Yes, you can, however the member function of the class must be static.

    Viggy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured