Error: Global variable type does not match previous declaration with same mangled name:

Adam D. Ruppe destructionator at gmail.com
Sun Nov 22 17:46:16 UTC 2020


So I'm trying to do this:

pragma(mangle, "_D" ~ T.mangleof[1..$] ~ "6__initZ")
// llvm says it is supposed to be { [2 x i8*]*, i8* }       
__gshared extern immutable idk initializer;


to do `emplace` in -betterC.


On dmd, I use `ubyte[__traits(classInstanceSize, T)]` as idk, but 
it doesn't check so it is all fine.

In ldc, I can't find anything that works. The closest I get is

         static struct idk { ubyte*[1]* a; }

But it still shows a different type. Since `T` is a class, and a 
D class is a reference if I use T as idk, it comes across as T* 
in the llvm type... and D can't express T itself.

This appears to the the code that generates the error:

https://github.com/ldc-developers/ldc/blob/c5b9f8a9048e46322301575546ed60fa79d5f2c9/gen/llvmhelpers.cpp#L1677

and I don't see an escape hatch....

I've tried using `void*`, `void[0]` and various things but I 
can't get ldc to accept it. I just want to get at the raw bytes 
defined by that symbol and I don't think the D language can 
actually express that.

Could ldc perhaps just relax the type checking with a pragma or 
something too? I don't see one in existing in the wiki but it 
might be useful at some point later to consider adding.


More information about the digitalmars-d-ldc mailing list