C Macro deeper meaning?

Alex Parrill via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jan 31 15:56:27 PST 2016


On Sunday, 31 January 2016 at 02:58:28 UTC, Andrew Edwards wrote:
> If I understand correctly, this piece of code:
>     enum NOTUSED(v) do { (void)(1 ? (void)0 : ( (void)(v) ) ); 
> } while(0)
>
> can be converted to the following in D:
>
>     void notUsed(T)(T v) { return cast(void)0; };
>
> since it always returns cast(void)0 regardless of the input.
>
> But it cannot be that simple, so what am I missing?
>
> Thanks,
> Andrew Edwards

Might want to change the function argument to `ref T v`, as 
struct postblits might run otherwise. Probably no reason to 
`return` either.


More information about the Digitalmars-d-learn mailing list