C Macro deeper meaning?

2016-01-30 Thread Andrew Edwards via Digitalmars-d-learn
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 tha

Re: C Macro deeper meaning?

2016-01-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 31 January 2016 at 02:58:28 UTC, Andrew Edwards wrote: But it cannot be that simple, so what am I missing? I'm guessing the macro was there in C to silence compiler warnings about not using a return value. So I think your translation is ok: NOTUSED(somefunction()); still cal

Re: C Macro deeper meaning?

2016-01-30 Thread Andrew Edwards via Digitalmars-d-learn
On Sunday, 31 January 2016 at 03:13:46 UTC, Adam D. Ruppe wrote: On Sunday, 31 January 2016 at 02:58:28 UTC, Andrew Edwards wrote: But it cannot be that simple, so what am I missing? I'm guessing the macro was there in C to silence compiler warnings about not using a return value. So I think

Re: C Macro deeper meaning?

2016-01-31 Thread Alex Parrill via Digitalmars-d-learn
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

Re: C Macro deeper meaning?

2016-02-01 Thread Kagamin via Digitalmars-d-learn
On Sunday, 31 January 2016 at 02:58:28 UTC, Andrew Edwards wrote: 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? Now notUsed has an unused parameter v.