Linux-wireless: why use macro to call functions

Greg Freemyer greg.freemyer at gmail.com
Tue Dec 24 08:35:34 EST 2013



Fred Chou <fred.chou.nd at gmail.com> wrote:

>Hi,
>
>On Mon, Dec 23, 2013 at 8:03 PM, Bernd Petrovitsch <
>bernd at petrovitsch.priv.at> wrote:
>[...]
>> And the macro just avoids to copy-paste identical lines/logic.
>
>Thank you all for the explanation. Originally I was wondering if there
>could be some other reasons. So the main (or only?) purpose of the
>macro is
>to save some typing, and in terms of functionality I could equivalently
>call each handlers.
>
>Fred

If you do decide to inline the code, you should probably get rid of the do while(0) part.

That exists just to get rid of side effects of using macros in various syntax situations.

http://c-faq.com/cpp/multistmt.html

Greg
-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20131224/7eaff5f3/attachment.html 


More information about the Kernelnewbies mailing list