On Wed, 14 Apr 1999, Aaron Ardiri wrote:
> On Wed, 14 Apr 1999, Aaron Ardiri wrote:
> > On Wed, 14 Apr 1999, Marc Balmer wrote:
> > > On Wed, 14 Apr 1999, you wrote:
> > >
> > > > does anyone have an explanation for this error?
> > >
> > > You have used a function which is found in the standard C library, e.g.
> > > strcpy. You should not use the functions but their Palm OS equivalent like
> > > StrCopy etc. If you need functionality from the standard (GNU) library,
> > > you have to install it somehow on the palm.
> >
> > hmm..
> >
> > if i am not using a GNU C library call.. what else could be the
> > problem?
> >
> > cheers.
>
> i have built two identical programs.. and located where this thing
> crashes.
>
> in my InitApplication() method i added the following lines:
>
> ---
> KeySetMask(~(
> moveLeftKey | moveRightKey |
> digLeftKey | digRightKey |
> climbUpKey | climbDownKey
> ));
> ---
>
> where... i have defined the following in a header file:
>
> ---
> #include <System/KeyMgr.h>
>
> #define digLeftKey keyBitHard1
> #define moveLeftKey keyBitHard2
> #define moveRightKey keyBitHard3
> #define digRightKey keyBitHard4
> #define climbUpKey pageUpChr
> #define climbDownKey pageDownChr
> ---
>
> any suggestions?
>
> i dont see any GNU stuff there..
1. You ARE doing a libc call, because you are linking to libc, and you
don't have LibC.prc installed. This is the only way you can get that
particular error.
2. Either post the whole source or the link map, i.e. do
m68k-palmos-coff-nm on the objects. You probably aren't calling it
quite where you think (maybe the line above or below the call you posted).
Just like the WinInitializeWindow caused the WinDeleteWindow to crash,
posting one line and saying why does it crash here would require me to be
psychic. Something might be #defined differently than you expect.
3. If you need string.h functions, the following are my inline set (they
won't actually be inlined without -O1 as a minimum). They also gave a
warning about const being dropped in the cmp functions. I haven't
verified them 100% (e.g. that they do exactly the right thing when the
count equals the string length), but they work for me, and I think are
faster and shorter.
/* linux (posix?) says val should be an int */
#include <string.h>
#define VALT char
extern inline void *memset(void *dst, VALT val, size_t num)
{
register void *ds = dst;
while (num--)
*((char *) dst)++ = val;
return ds;
}
extern inline void *memcpy(void *dst, const void *src, size_t num)
{
register void *ds = dst;
while (num--)
*((char *) dst)++ = *((char *) src)++;
return ds;
}
extern inline int memcmp(void *dst, const void *src, size_t num)
{
while (num-- && (*((char *) dst)++ == *((char *) src)++));
if (num >= 0)
return *--((char *) dst) - *--((char *) src);
else
return 0;
}
extern inline void *memccpy(void *dst, const void *src, int c, size_t num)
{
register void *ds = dst;
while (num-- && *((char *) src) != c)
*((char *) dst)++ = *((char *) src)++;
if (num >= 0)
*((char *) dst)++ = *((char *) src)++;
return ds;
}
extern inline void *memmove(void *dst, const void *src, size_t num)
{
register void *ds = dst;
if (dst < src || dst >= src + num)
while (num--)
*((char *) dst)++ = *((char *) src)++;
else {
dst += num;
src += num;
while (num--)
*--((char *) dst) = *--((char *) src);
}
return ds;
}
extern inline size_t strlen(char *dst)
{
register size_t num = 0;
while ((*dst++))
num++;
return num;
}
extern inline char *strcat(char *dst, const char *src)
{
register char *ds = dst;
while (*dst)
dst++;
while ((*dst++ = *src++));
return ds;
}
extern inline char *strncat(char *dst, const char *src, size_t num)
{
register char *ds = dst;
while (*dst)
dst++;
while (num-- && (*dst++ = *src++));
return ds;
}
extern inline char *strcpy(char *dst, const char *src)
{
register char *ds = dst;
while ((*dst++ = *src++));
return ds;
}
extern inline int strcmp(const char *dst, const char *src)
{
while (*dst && *src && (*dst++ == *src++));
if (*dst && *src)
return *--src - *--dst;
else
return *src - *dst;
}
extern inline int strncmp(const char *dst, const char *src, size_t num)
{
while (num && *dst && *src && (*dst++ == *src++))
num--;
if( !num )
return 0;
if (*dst && *src)
return *--src - *--dst;
else
return *src - *dst;
}
extern inline char *strncpy(char *dst, const char *src, size_t num)
{
register char *ds = dst;
while (num-- && (*dst++ = *src++));
if (num >= 0)
while (num--)
*dst++ = 0;
return ds;
}
extern inline void *memchr(const void *dst, VALT val, size_t num)
{
char *dstl = (void *)dst;
while (num-- && *dstl++ != val);
if (num >= 0)
return (void *) --dstl;
else
return NULL;
}
extern inline char *strchr(const char *dst, int val)
{
char *dstl = (char *)dst;
while (*dstl && *dstl != val)
dstl++;
if (*dstl != val)
return NULL;
else
return dstl;
}