1

I'm trying to compile the SDL libraries with Visual C++ (2010), and with Visual Leak Detector as to find a memory leak in another program that calls SDL.

The problem is that vld.h is a C++ library, and SDL.c is a C program. Accordingly, when I #include , the source doesn't compile as VLD seems to use a C++ specific constructs:

typedef int (__cdecl * VLD_REPORT_HOOK)(int reportType, wchar_t *message, int *returnValue);

__declspec(dllimport) int VLDSetReportHook(int mode,  VLD_REPORT_HOOK pfnNewHook);

I've attempted compiling SDL.c as a C++ program, but I get a plethora of errors.

Is there any way I can include VLD in SDL?

4

1 回答 1

3

(with thanks to @Matias Valdenegro)

The problem was the wchar_t. To be able to recompile SDL (and I assume other C source files) to include VLD, add

#include <wchar.h>

to both vld.h and vld_def.h. SDL will then happily compile, and can be used with an SDL program to detect memory leaks stemming from Surfaces and the like.

于 2012-01-09T10:34:59.950 回答