static assignment

Igor via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jan 25 17:40:16 PST 2016


how can I have a static assignment


	static bool isStarted = false;
	public static Application Start(string Name, void 
function(Application) entryPoint)
	{
		if (isStarted)
			assert("Can only call Start once");
                 isStarted = true;
         ...

but I don't want this a runtime check. I want to know at compile 
time. Start should never be used more than once in the entire 
program. It's only used to get control from windows startup. It's 
only called in the static this() of the main module.

changing stuff to static if and static assert doesn't help. I 
tried enum, const, etc but all prevent setting isStarted to true.









More information about the Digitalmars-d-learn mailing list