Is there a way to replace Exception with as a macro in C?

yisooan yisooan at
Tue Feb 19 05:50:04 UTC 2019

I wonder there is the way as I said in the title. For instance,

in C,
> #define indexInvalidException Exception("The index is invalid")
> /* Do something with the macro here */
> if (false)
>   indexInvalidException;

This is allowed.
But I want to do the exact same thing in D. I have already tried 
some expressions with alias? but it doesn't work.

> alias indexInvalidException = Exception("The index is invalid");
> /* Use the alias in somewhere */
> if (false)
>   throw new indexInvalidException;

Would you help me, please?

More information about the Digitalmars-d-learn mailing list