autowrap
autowrap copied to clipboard
Error in wrapCSharp on Windows
Thank you for the interesting library.:+1:
I tried the wrapCSharp
on Windows, but a compile error occurred.
Error: only one main, WinMain, or DllMain allowed. Previously found main at source\csharp\wrapper.d-mixin-6(100,31)
The cause is the following in boilerplate.d. https://github.com/kaleidicassociates/autowrap/blob/master/csharp/source/autowrap/csharp/boilerplate.d#L43
I avoided errors in the following way, because I wanted to run examples.
//Insert DllMain for Windows only.
version(Windows) {
version(EmitCSharp) {
} else {
%3$s
}
}
version (EmitCSharp) {
void main() {
import std.stdio;
string generated = generateCSharp!(%2$s)(LibraryName("%4$s"), RootNamespace("%5$s"));
auto f = File("%6$s", "w");
f.writeln(generated);
}
}
I'm glad if it is fixed.
Regards
@lempiji Did you attempt to build both python and C# bindings into the same library? Right now both the python bindings and the C# bindings insert the DllMain. The workaround would be to generate them as seperate libraries for the moment.
@atilaneves A static if based on an enum that is defined inside the version statement is probably the best fix here correct? I don't want to break your python code.
I think the best way here is to move DllMain
to a separate subpackage and have both python and csharp packages depend on it, then yes, probably check with a static if if DllMain
has previously been defined or not.
@LightBender No, I used only for C#. And I just built the examples/csharp.
I think that it is a good idea to separate it into subpackage.