On Saturday, 27 July 2019 at 11:54:09 UTC, BoQsc wrote:
I would like to make sure that function in module that I have
won't be imported, is this possible to achieve?
Test subject:
mainFile.d
import otherFile;
void main(){
}
otherFile.d
import std.stdio : writeln;
import std.file : mkdir;
int main(){
writeln("test ");
return 0;
}
Error, main() method has been imported:
how to disallow main() method from being imported?
otherFile.d(5): Error: only one main, WinMain, or DllMain
allowed. Previously found main at mainFile.d(3)
This has nothing to do with main being imported. It's because you
*compiled* two main functions. If you absolutely want two main
functions and can't see a better way to achieve whatever it is
you're doing, then you can wrap them in version blocks:
module mainFile;
version(defaultMain) {
...
}
=========
module otherFile;
version otherMain() {
...
}