That typechecks the return value but that's not where the bulk of the errors are made. I want the parameters to be checked. Shown is one solution. The errors will be caught in any DEBUG build and the release builds will run at full speed with one typecheck.
#ifdef DEBUG
EXTERNC CHAR *amemcpy(CHAR *v1,const CHAR *v2,size_t n) {
return (CHAR *)memcpy(v1,v2,n);
}
#else
#define amemcpy(v1, v2, n) ((char*)memcpy(v1, v2, n))
#endif
CHAR test[5];
memset(&test,0,sizeof(test)); // 1 warning in Watcom, 0 warnings in Pelles
WCHAR testW[5];
wmemset(&testW,0,NELEM(testW)); // 1 error
WCHAR *v1,*v2;
WCHAR *vr=amemcpy(v1,v2,0); // 1 error, no warnings
CHAR *c1,*c2;
CHAR *vc=wmemcpy(c1,c2,0); // 3 errors, no warnings