Skip to content

core.stdc definition conflicts with ldc2 #286

@aminya

Description

@aminya

When I use ldc2 to build a C library, I get these kinds of errors if my d file uses std.stdio

dmd works fine without any issues!

> d++ --compiler=ldc2 file.dpp file.lib entry.d

C:\tools\ldc2-1.24.0-windows-x64\bin\..\import\core\stdc\stdio.d(1317): Error: Function type does not match previously declared function with the same mangled name: `fwrite`
C:\tools\ldc2-1.24.0-windows-x64\bin\..\import\core\stdc\stdio.d(1317):        Previous IR type: i64 (i8*, i64, i64, %file._iobuf*)
C:\tools\ldc2-1.24.0-windows-x64\bin\..\import\core\stdc\stdio.d(1317):        New IR type:      i64 (i8*, i64, i64, %core.stdc.stdio._iobuf*)

This is because I have writeln("hello"); in the main function of entry.d which imports file.

I noticed that dpp generates these conflicting definitions.

    alias FILE = _iobuf;
    struct _iobuf
    {
        void* _Placeholder;
    }
    ulong fwrite(const(void)*, ulong, ulong, _iobuf*) @nogc nothrow;

The issue is the same on Ubuntu or Windows.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions