I do not recommend doing this; this is terrible code and if you are using C you should compile it with a C compiler (or, in Visual C++, as a C file)
If you are using Visual C++, you can use decltype
:
#define MALLOC_SAFE(var, size) \
{ \
var = static_cast(malloc(size)); \
if (!var) goto error; \
}