digitalmars.D.learn - Is this a compiler issue?
- DLearner (48/48) Dec 06 2025 Hi
Hi
This uses DMD64 D Compiler v2.111.0, using -betterC, under
Windows 10.
With the two commented lines in place, results are as expected.
Uncomment those two lines, even though the variable is set but
never used,
the program fails at the link stage with reference to a missing
'_memsetn'.
Ideas?
```
extern(C) void main() {
import core.stdc.stdio : printf;
import testmod : sub1 , TestStruct;
int IntVar1 = 5;
TestStruct[1] TS1;
TS1[0].VarAddr = &IntVar1;
TS1[0].VarName = "IntVar1";
TS1[0].VarInt = 3;
// TS1[0].VarType = 'N';
printf("ppm_th: Entered.\n");
printf("ppm_th: Calling sub1...\n");
sub1(TS1);
printf("ppm_th: Returned from sub1.\n");
printf("ppm_th: Exiting...\n");
}
```
The module 'testmod':
```
struct TestStruct {
void* VarAddr;
string VarName;
int VarInt;
// char VarType;
}
void sub1(TestStruct[] parmTestStruct) {
import core.stdc.stdio : printf;
printf("sub1: Entered.\n");
int* VarAddr;
size_t wkIdx;
for (wkIdx = 0; wkIdx < parmTestStruct.length; wkIdx = wkIdx +
1) {
VarAddr = cast(int*)(parmTestStruct[wkIdx].VarAddr);
printf("*VarAddr = %d\n", *VarAddr);
printf("\n");
}
printf("sub1: Exiting...\n");
}
```
Dec 06 2025
On Saturday, 6 December 2025 at 19:36:01 UTC, DLearner wrote:Hi This uses DMD64 D Compiler v2.111.0, using -betterC, under Windows 10. With the two commented lines in place, results are as expected. Uncomment those two lines, even though the variable is set but never used, the program fails at the link stage with reference to a missing '_memsetn'. Ideas?I think the problem here is the type `struct[N]` with the betterC flag. Try replacing `TestStruct[1] TS1;` with `TestStruct TS1;` and `sub1(TS1);` with `sub1((&TS1)[0 .. 1]);`, and things should work fine. If I am right and you want to use a static array of structs without defining this function yourself, then you could copy-paste [this code](https://github.com/Kapendev/joka/blob/main/source/joka/types.d#L61) in your project.
Dec 06 2025
On Saturday, 6 December 2025 at 21:20:37 UTC, Kapendev wrote:If I am right and you want to use a static array of structs without defining this function yourself, then you could copy-paste [this code](https://github.com/Kapendev/joka/blob/main/source/joka/types.d#L61) in your project.Well, the [microui-d version](https://github.com/Kapendev/microui-d/blob/main/source/microui.d#L209) of this is easier to copy-paste.
Dec 06 2025
On Saturday, 6 December 2025 at 21:23:22 UTC, Kapendev wrote:On Saturday, 6 December 2025 at 21:20:37 UTC, Kapendev wrote:Thanks for your suggestion. Best regards DLIf I am right and you want to use a static array of structs without defining this function yourself, then you could copy-paste [this code](https://github.com/Kapendev/joka/blob/main/source/joka/types.d#L61) in your project.Well, the [microui-d version](https://github.com/Kapendev/microui-d/blob/main/so rce/microui.d#L209) of this is easier to copy-paste.
Dec 06 2025
On Sunday, 7 December 2025 at 00:06:14 UTC, DLearner wrote:On Saturday, 6 December 2025 at 21:23:22 UTC, Kapendev wrote:Yeah, could be. My solution does not need these function.On Saturday, 6 December 2025 at 21:20:37 UTC, Kapendev wrote:Thanks for your suggestion. Best regards DLIf I am right and you want to use a static array of structs without defining this function yourself, then you could copy-paste [this code](https://github.com/Kapendev/joka/blob/main/source/joka/types.d#L61) in your project.Well, the [microui-d version](https://github.com/Kapendev/microui-d/blob/main/so rce/microui.d#L209) of this is easier to copy-paste.
Dec 07 2025








Kapendev <alexandroskapretsos gmail.com>