From C to D: issue with arguments for core.stdc.string.memcpy
Meta
jared771 at gmail.com
Fri Feb 22 16:38:10 UTC 2019
On Wednesday, 20 February 2019 at 20:57:26 UTC, Mike Parker wrote:
> On Wednesday, 20 February 2019 at 20:46:42 UTC, Alec Stewart
> wrote:
>
>>
>> The error
>>
>> onlineapp.d(42): Error: function
>> core.stdc.string.memcpy(return scope void* s1, scope
>> const(void*) s2, ulong n) is not callable using argument types
>> (char[31], const(char)*, ulong)
>> onlineapp.d(42): cannot pass argument
>> (*s).stack.buffer of type char[31] to parameter return scope
>> void* s1
>>
>>
>> SO, with all of that; how can I fix this? Do I have to do some
>> ugly type casting?
>>
>
> You're passing a static array where the function expects a
> pointer.
>
> memcpy(s.stack.buffer.ptr, input, n);
To expand on this just a bit, in case you're not familiar with D,
arrays in D do not decay to a pointer like they do in C. You need
to pass s.stack.buffer.ptr instead.
More information about the Digitalmars-d
mailing list