digitalmars.D.learn - betterC: string mixins in module - again
- DLearner (54/54) Dec 30 2025 Got a highly reduced example:
- Richard (Rikki) Andrew Cattermole (5/18) Dec 30 2025 Yeah static arrays have trouble initializing in -betterC.
- Kapendev (2/7) Dec 30 2025 
Got a highly reduced example:
The following code works perfectly
```
extern(C) void main() {
string mxnInit(string parmScrnDef) {
if(__ctfe) {
return `{` ~
`enum NoOfScrns = 4;` ~
`string [NoOfScrns] ScreenNames;` ~
`import core.stdc.stdio : printf;
printf("NoOfScrns = %d\n", cast(int)(NoOfScrns)); ` ~
`}`;
} else {
return ``;
}
}
mixin(mxnInit("NPL4"));
}
```
But split things so that ctfemod contains
```
string mxnInit(string parmScrnDef) {
if(__ctfe) {
return `{` ~
`enum NoOfScrns = 4;` ~
`string [NoOfScrns] ScreenNames;` ~
`import core.stdc.stdio : printf;
printf("NoOfScrns = %d\n", cast(int)(NoOfScrns)); ` ~
`}`;
} else {
return ``;
}
}
```
Called from a master:
```
extern(C) void main() {
import ctfemod;
mixin(mxnInit("NPL4"));
}
```
And we get: (DMD64 D Compiler v2.111.0)
```
ctfemst.obj : error LNK2019: unresolved external symbol
_memset128ii referenced in function main
ctfemst.exe : fatal error LNK1120: 1 unresolved externals
Error: linker exited with status 1120
C:\Program Files\Microsoft Visual
Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64\link.exe
/NOLOGO "ctfemst.obj" /LIBPATH:"C:\Program Files\Microsoft Visual
Studio\2022\Community\VC\Tools\MSVC\14.41.34120\lib\x64"
legacy_stdio_definitions.lib /LIBPATH:"C:\Program Files (x86)\Windows
Kits\10\Lib\10.0.22000.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Windows
Kits\10\lib\10.0.22000.0\um\x64"
Error: undefined reference to `_memset128ii`
referenced from `main`
perhaps a library needs to be added with the `-L` flag or
`pragma(lib, ...)`
```
Dec 30 2025
On 31/12/2025 12:39 PM, DLearner wrote:And we get: (DMD64 D Compiler v2.111.0) ``` ctfemst.obj : error LNK2019: unresolved external symbol _memset128ii referenced in function main ctfemst.exe : fatal error LNK1120: 1 unresolved externals Error: linker exited with status 1120 C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64\link.exe /NOLOGO "ctfemst.obj" /LIBPATH:"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\lib\x64" legacy_stdio_definitions.lib /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64" Error: undefined reference to `_memset128ii` referenced from `main` perhaps a library needs to be added with the `-L` flag or `pragma(lib, ...)` ```Yeah static arrays have trouble initializing in -betterC. But only with dmd. https://github.com/dlang/dmd/blob/master/druntime/src/rt/memset.d#L83 https://github.com/dlang/dmd/issues/19579
Dec 30 2025
On Tuesday, 30 December 2025 at 23:39:40 UTC, DLearner wrote:string mxnInit(string parmScrnDef) { if(__ctfe) { ctfemst.obj : error LNK2019: unresolved external symbol _memset128ii referenced in function main Error: undefined reference to `_memset128ii`
Dec 30 2025









"Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> 