Subject:
|
Re: legOS & C
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Wed, 3 Feb 1999 06:07:57 GMT
|
Original-From:
|
John A. Tamplin <jat@traveller.comANTISPAM>
|
Viewed:
|
1043 times
|
| |
| |
On Tue, 2 Feb 1999, Alex Howansky wrote:
> Cygwin B20.1
> legOS 0.16
>
> Whenever I try to do a declaration initialization of an array:
>
> int thing[] = {0x01,0x02,0x03};
>
> I get a failure on linking:
>
> "undefined reference to memcpy"
>
> The code compiles and runs fine when compiled for x86. I can always work
> around it with:
>
> thing[0] = 0x01;
> thing[1] = 0x02;
>
> ... but that's hardly the best solution. Anyone have an idea?
What compiler are you using? I was unable to duplicate this behavior
with egcs-1.1 -- for static integer arrays it outputs .word pseudo-ops
and for automatic arrays that small it generates inline code to initialize
each element.
In any case, the problem is that the compiler calls the standard library
function memcpy to copy the bytes into the target array. memcpy in legOS
is not a function but instead a macro, so there is no way to call it.
I actually use a stripped down libc, which includes an implementation of
memcpy (as well as all the str functions, etc). If you don't want to do
that, just create a simple memcpy.c and link it in:
void *memcpy(void *dest,const void *src,unsigned n) {
unsigned char *d,*s;
d=(unsigned char *)dest;
s=(unsigned char *)src;
while(n) {
*d++ = *s++;
n--;
}
return dest;
}
This isn't the most efficient implementation, but it will work. If you want
a faster one you can either put in the same assembly code that the memcpy
macro uses or you can use a more sophisticated memcpy such as that from GNU
libc.
John A. Tamplin Traveller Information Services
jat@Traveller.COM 2104 West Ferry Way
256/705-7007 - FAX 256/705-7100 Huntsville, AL 35801
--
Did you check the web site first?: http://www.crynwr.com/lego-robotics
|
|
Message has 1 Reply: | | Re: legOS & C
|
| (...) I'm using Gavin's gcc package from (URL) I actually use a stripped down libc, which includes an implementation of (...) That sounds great -- the string functions would be very nice to have. Do you have a URL for reference, or do I have to (...) (26 years ago, 3-Feb-99, to lugnet.robotics)
|
Message is in Reply To:
| | legOS & C
|
| Cygwin B20.1 legOS 0.16 Whenever I try to do a declaration initialization of an array: int thing[] = {0x01,0x02,0x03}; I get a failure on linking: "undefined reference to memcpy" The code compiles and runs fine when compiled for x86. I can always (...) (26 years ago, 3-Feb-99, to lugnet.robotics)
|
3 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|