Pelles C forum

Pelles C => Feature requests => Topic started by: severach on October 13, 2006, 04:37:03 PM

Title: Can't inline an inline
Post by: severach 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);
}
Title: Can't inline an inline
Post by: Sanguis 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))
Title: Can't inline an inline
Post by: severach 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