core.thread.memcpy conflicts with core.stdc.string.memcpy

Marco Leise via Digitalmars-d digitalmars-d at puremagic.com
Fri Oct 17 02:28:17 PDT 2014


When I read that error I wondered why anyone would define a
function for threads with the same name as a well established
C function. On a closer look it revealed to be just another
name for the same extern(C) memcpy to avoid the import of
core.stdc.string in core.thread:

private
{
    import core.sync.mutex;
    import core.atomic;

    //
    // from core.memory
    //
    extern (C) void  gc_enable();
    extern (C) void  gc_disable();
    extern (C) void* gc_malloc(size_t sz, uint ba = 0);

    //
    // from core.stdc.string
    //
    extern (C) void* memcpy(void*, const void*, size_t);

    //
    // exposed by compiler runtime
    //
    extern (C) void  rt_moduleTlsCtor();
    extern (C) void  rt_moduleTlsDtor();

    alias void delegate() gc_atom;
    extern (C) void function(scope gc_atom) gc_atomic;
}

Well, it is mildly annoying. `private` doesn't really help in
the way the author expected it to work here.

-- 
Marco



More information about the Digitalmars-d mailing list