Can't inline an inline

Started by severach, October 13, 2006, 04:37:03 PM

Previous topic - Next topic

severach

memcpy() is inline code. When I try to make a typechecked version it won't inline.
__inline CHAR * amemcpy(CHAR *szDest,CHAR *szSource,size_t cchCount) {
 return (CHAR *)memcpy(szDest,szSource,cchCount);
}

Sanguis

If you want to typecheck it, you can use this method:
#define amemcpy(v1, v2, n)  ((char*)memcpy(v1, v2, n))

severach

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