From: greg.freemyer@gmail.com (Greg Freemyer) Date: Tue, 24 Dec 2013 08:35:34 -0500 Subject: Linux-wireless: why use macro to call functions In-Reply-To: References: <52b80f05.c7b60e0a.2515.5c5e@mx.google.com> <1387800180.1784.65.camel@thorin> Message-ID: <59f4ee74-40f0-4d8b-9c63-fde067fb3ebc@email.android.com> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org Fred Chou 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