[OT] #define

Andrew Edwards via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 22 09:39:23 PDT 2017


On Monday, 22 May 2017 at 13:18:51 UTC, Eugene Wissner wrote:
> On Monday, 22 May 2017 at 13:11:15 UTC, Andrew Edwards wrote:
>> Sorry if this is a stupid question but it eludes me. In the 
>> following, what is THING? What is SOME_THING?
>>
>>     #ifndef THING
>>     #define THING
>>     #endif
>>
>>     #ifndef SOME_THING
>>     #define SOME_THING THING *
>>     #endif
>>
>> Is this equivalent to:
>>
>>     alias thing = void;
>>     alias someThing = thing*;
>>
>> Thanks,
>> Andrew
>
> No, it isn't. THING is empty. Some SOME_THING is "*".
>
> Emtpy macros are used for example to inline the functions:
>
> #ifndef MY_INLINE
> #define MY_INLINE
> #endif
>
> MY_INLINE void function()
> {
> }
>
> So you can choose at compile time if you want inline the 
> function or not. D is here more restrictive than C, I don't 
> know a way to port to D.

Thanks Eugene, got it. For context, see response to Adam.


More information about the Digitalmars-d-learn mailing list