Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.apple2.programmer > #1321
| From | Charlie <charlieDOTd@verEYEzon.net> |
|---|---|
| Newsgroups | comp.sys.apple2.programmer |
| Subject | Re: memcpy crash |
| Date | 2014-09-26 14:17 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <m04ais$h8g$1@dont-email.me> (permalink) |
| References | <63dd489a-6736-45ab-bff3-0012e4a60e41@googlegroups.com> <m0426r$i7m$1@dont-email.me> <df99f84a-10b2-43a8-95bc-a5c3e637e3ca@googlegroups.com> |
On 9/26/2014 1:06 PM, AppleIIGSMarc wrote:
> On Friday, September 26, 2014 8:54:32 AM UTC-7, Charlie wrote:
>> On 9/26/2014 4:57 AM, AppleIIGSMarc wrote:
>>
>>> I've been working on a program in ORCA/C (version 2.1.0) and, for some reason, it crashes anytime I try to call memcpy. In an effort to figure out what's going on, I wrote the simplest program I could think of to test it out...
>>
>>>
>>
>>> //--------------------------------------
>>
>>>
>>
>>> #include<memory.h>
>>
>>>
>>
>>> int source[64];
>>
>>> int dest[64];
>>
>>>
>>
>>> int main(void)
>>
>>> {
>>
>>> memcpy(dest, source, 16);
>>
>>>
>>
>>> return 0;
>>
>>> }
>>
>>>
>>
>>> //--------------------------------------
>>
>>>
>>
>>> This crashes for me every time I try to run it. The number of bytes transferred doesn't seem to matter, it crashes even if it's set to 1 byte. Also, manually copying the data with a for loop and setting each element one-by-one works with no problems. It's late, so I may be doing something really stupid, but I'm not seeing it. Does anyone have any idea what the problem may be?
>>
>>>
>>
>>> Thanks!
>>
>>
>>
>> I think you need to #include<string.h> not<memory.h>.
>>
>>
>>
>> Charlie
>
> Thanks, that was the problem...I did say it was late, right? :) But I'm really surprised that the linker didn't complain about an unresolved reference.
Yes, I think it should and it certainly shouldn't crash.
> I tried compiling the program with NO includes at the top and it still linked successfully. Apparently the linker will find any standard C function even without the proper headers? I tried printf, strcpy, getchar and they all link successfully (and actually work unlike memcpy).
Is this the expected behavior in Ansi C or is it just Orca?
I'm not sure if finding the "standard" libraries is expected behavior in
ANSI C but ANSI did change some of the "standard" functions.
Charlie
Back to comp.sys.apple2.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
memcpy crash AppleIIGSMarc <appleiigsmarc@gmail.com> - 2014-09-26 01:57 -0700
Re: memcpy crash Charlie <charlieDOTd@verEYEzon.net> - 2014-09-26 11:54 -0400
Re: memcpy crash AppleIIGSMarc <appleiigsmarc@gmail.com> - 2014-09-26 10:06 -0700
Re: memcpy crash Charlie <charlieDOTd@verEYEzon.net> - 2014-09-26 14:17 -0400
Re: memcpy crash Steven Hirsch <snhirsch@gmail.com> - 2014-09-26 16:31 -0400
Re: memcpy crash dempson@actrix.gen.nz (David Empson) - 2014-09-27 13:22 +1200
Calling conventions (was Re: memcpy crash) "Anton Treuenfels" <teamtempest@yahoo.com> - 2014-09-27 11:11 -0500
Re: Calling conventions dempson@actrix.gen.nz (David Empson) - 2014-09-28 14:13 +1300
Re: Calling conventions (was Re: memcpy crash) Michael J. Mahon <mjmahon@aol.com> - 2014-09-28 14:56 -0500
Re: Calling conventions (was Re: memcpy crash) "Anton Treuenfels" <teamtempest@yahoo.com> - 2014-09-28 23:21 -0500
Re: memcpy crash Kelvin Sherlock <email@domain.com> - 2014-09-26 14:47 -0400
csiph-web