Stop compilation in code

Is there some kind of Pragma that stops compiling because, for example, an error occurred? I know about pragma(msg, ...) , but this only prints an error and does not actually stop compiling.

The reason I want this is because in some cases there are a lot of errors that do not really make sense, so I would like to β€œoverride” these errors by putting my own clear message.

+7
assert d pragma
source share
2 answers
 static assert(false, "Your Message") 

Aborts compilation.

+11
source share

You can use static assert to stop compilation. Example:

 version(Windows) static assert(false, "Windows is not supported"); 
+6
source share

All Articles