On Monday, 17 March 2025 at 12:28:38 UTC, Maximilian Naderer wrote:
Hello people,

i have the following example. Compiled with dmd and ldc2

dmd main.d -betterC
ldc2 main.d -betterC

with dmd the compilation fails with

    lld-link: error: undefined symbol: _memsetFloat
    >>> referenced by app.obj:(main)
    Error: linker exited with status 1
C:\dev\dlang\dmd2\windows\bin64\lld-link.exe /NOLOGO "app.obj" /LIBPATH:"C:\dev\dlang\dmd2\windows\bin64\..\lib64\mingw

The compilation fails only with dmd when I'm not assigning all the fields of a struct like in example #3. Is this a compiler error ?

```d
struct MyStruct {
    float[4] data;
    float[16] matrix;
}

extern(C) int main() {


    MyStruct sWorks = MyStruct(
        data: [1.0f, 2.0f, 3.0f, 4.0f],
        matrix: [
            1.0f, 0.0f, 0.0f, 0.0f,
            0.0f, 1.0f, 0.0f, 0.0f,
            0.0f, 0.0f, 1.0f, 0.0f,
            0.0f, 0.0f, 0.0f, 1.0f
        ]);

    MyStruct sWorks2;
    sWorks2.data = [ 1.0f, 0.0f, 0.0f, 1.0f ];

    MyStruct sNotWorking = MyStruct(
        data: [ 1.0f, 0.0f, 0.0f, 1.0f ],
        matrix: [
            1.0f, 0.0f, 0.0f, 0.0f,
            0.0f, 1.0f, 0.0f, 0.0f,
            0.0f, 0.0f, 1.0f, 0.0f,
            0.0f, 0.0f, 0.0f, 1.0f
        ]);


    return 0;
}
```

Sorry the example should have been

```d
struct MyStruct {
    float[4] data;
    float[16] matrix;
}

extern(C) int main() {


    MyStruct sWorks = MyStruct(
        data: [1.0f, 2.0f, 3.0f, 4.0f],
        matrix: [
            1.0f, 0.0f, 0.0f, 0.0f,
            0.0f, 1.0f, 0.0f, 0.0f,
            0.0f, 0.0f, 1.0f, 0.0f,
            0.0f, 0.0f, 0.0f, 1.0f
        ]);

    MyStruct sWorks2;
    sWorks2.data = [ 1.0f, 0.0f, 0.0f, 1.0f ];

    MyStruct sNotWorking = MyStruct(
        matrix: [
            1.0f, 0.0f, 0.0f, 0.0f,
            0.0f, 1.0f, 0.0f, 0.0f,
            0.0f, 0.0f, 1.0f, 0.0f,
            0.0f, 0.0f, 0.0f, 1.0f
        ]);


    return 0;
}
```

Reply via email to