Page 1 of 1
reference to memcpy
Posted: Wed Oct 15, 2003 6:38 am
by gedeon
Hi , i have the following problem
when i start make for my os project i have this error :
undefined reference to 'memcpy'
but i don't use memcpy
on my old system with gcc 3.2.2 it works fine
with gcc 3.3 it doesn't why ?
maybe the change between this two version is the problem
is there a command option to workarround this problem ?
Re:reference to memcpy
Posted: Wed Oct 15, 2003 7:21 am
by Pype.Clicker
GCC may need memcpy to perform language operations like structures copies (i.e. when you have
struct stuff=other_stuff;). The easiest workaround is to provide your own memcpy function, for instance with
Code: Select all
static inline void *memcpy(void *dest, const void *src, int n) {
char *dst=dest;
for (;n;n--,dest++,src++)
*dst=*((char*)src);
return dest;
}
or any equivalent code you might find smarter (using rep stosb, or using integer moves rather than byte moves when both addresses are aligned on an integer boundary and n>4 ... whatever ...)
Re:reference to memcpy
Posted: Thu Oct 16, 2003 12:30 pm
by gedeon
Thanks a lot , it works fine
In order to understand , why the problem appears ?
I have not changed my source code when i have switched my systems. And with GCC 3.2, there was no error.
Does anymore function that i have to provide ?
Re:reference to memcpy
Posted: Thu Oct 16, 2003 1:57 pm
by kaos
gedeon wrote:
Thanks a lot , it works fine
In order to understand , why the problem appears ?
I have not changed my source code when i have switched my systems. And with GCC 3.2, there was no error.
Does anymore function that i have to provide ?
It is hard to say why really. I'd think that both versions would have a memcpy() builtin. Have you changed the command line arguments? Are you building on the same OS with a different compiler or are there other differences? Were the compilers built the same?
Upgrading to a new version of gcc doesn't usually break code; they are pretty good about that sort of thing. In general, gcc is a fantastic compiler.
Gas, on the other hand, is a monstrosity... but I digress.
Re:reference to memcpy
Posted: Fri Oct 17, 2003 8:36 am
by gedeon
The code source didn't change
before
red hat 9, kdevelop 2.1.5, gcc 3.2.2
after
Suse 8.2 , kdevelop 2.1.5, gcc 3.3
strange !!!