NO

Author Topic: Can't inline an inline  (Read 3459 times)

severach

  • Guest
Can't inline an inline
« on: October 13, 2006, 04:37:03 PM »
memcpy() is inline code. When I try to make a typechecked version it won't inline.
Code: [Select]
__inline CHAR * amemcpy(CHAR *szDest,CHAR *szSource,size_t cchCount) {
  return (CHAR *)memcpy(szDest,szSource,cchCount);
}

Sanguis

  • Guest
Can't inline an inline
« Reply #1 on: October 14, 2006, 07:22:29 PM »
If you want to typecheck it, you can use this method:
Code: [Select]
#define amemcpy(v1, v2, n)  ((char*)memcpy(v1, v2, n))

severach

  • Guest
Can't inline an inline
« Reply #2 on: October 15, 2006, 01:24:22 AM »
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.
Code: [Select]

#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