Is it possible to disallow import for certain functions?

evilrat evilrat666 at gmail.com
Sat Jul 27 13:12:32 UTC 2019


On Saturday, 27 July 2019 at 12:48:12 UTC, BoQsc wrote:
>
> I seem to be doing something wrong, the result is the same.
>> otherFile.d(8): Error: only one main, WinMain, or DllMain 
>> allowed. Previously found main at mainFile.d(11)
>
>
>>
>>private version = otherMain;
>>version(otherMain) {
>>	void main(){
>>		writeln("Interesting");
>>	}
>>}

Of course. When you import that module "version = ..." is likely 
still evaluated and it enables that second main. Either move it 
to yet another module(and that's just masks the problem) or use 
command-line parameter to toggle which one to use.


More information about the Digitalmars-d-learn mailing list