Very clever compiling error with mangling
mesni
mensikovk817 at gmail.com
Sat Jun 4 20:32:26 UTC 2022
On Saturday, 4 June 2022 at 20:22:31 UTC, kinke wrote:
> On Saturday, 4 June 2022 at 20:09:45 UTC, mesni wrote:
>> ```
>> source\api.d(6,5): Error: Function type does not match
>> previously declared function with the same mangled name:
>> `_D3api8testFuncFiiZi`
>> source\api.d(6,5): Previous IR type: void ()
>> source\api.d(6,5): New IR type: i32 (i32, i32)
>> ```
>
> The D snippet you posted has apparently nothing to do with the
> error. It's complaining about 2 different signatures (in
> different modules) for some `int api.testFunc(int, int)`, with
> one being a `void()` (and so definitely not matching the
> mangled signature). Likely an incompatible signature in an
> `api.di`.
This is a fragment of the string from which the function is
generated.
```d
mixin({
import std.array;
string result = q{
__gshared extern(C) static void* dpford_funcp_DMANGLE;
pragma(mangle, "DMANGLE")
void dpford_func_DMANGLE() {
asm{
naked;
jmp dpford_funcp_DMANGLE;
}
}
};
return result.replace("DMANGLE", n.mangleof);
}());
```
The function declarations themselves
```d
In api.di
module api;
enum SorrelAPI;
@SorrelAPI
int testFunc(int, int);
```
The other module in the mixin template reads all the changled
function names from that module.
More information about the digitalmars-d-ldc
mailing list