I use macros extensively as well. It makes code easier to write, easier=20 to read and easier to maintain. But there ARE things to watch out for. =20 Once a macro is written and placed out of sight, it is easy to forget it=20 even IS a macro. The classic example: #define TOUPPER(c) ('a' <=3D (c) && (c) <=3D 'z' ? (c) - 'a' + 'A' : (c)) works great, until you use selection =3D TOUPPER(getch()); which expands to ('a' <=3D (getch()) && (getch()) <=3D 'z' ? (getch()) - 'a' + 'A' : (getch= ())) and it goes to the keyboard 4 times when it seems to do so only once. Kerry James Newton wrote: > Fine. > > I've written rather a lot of code and I use macros extensively to make th= at > code more configurable, flexible, and easier to read. I've never been bit= ten > by anything I would call "macro misuse", I have no idea why anyone would > have trouble with them, and you made a general statement without any > reference or proof so I assumed you were objecting to the language as a > whole.=20 > > If you can point out any danger from the macros I'm sharing, please give = an > example or reference and I'll apologize. If you just want to wave flags i= n > the air without actually being helpful, go away. > > -- > James Newton > 1-970-462-7764=20 > > -----Original Message----- > From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf = Of > Michael Watterson > Sent: Monday, July 11, 2011 03:20 > To: Microcontroller discussion list - Public. > Subject: Re: [PIC] Using macros to simplify port operations in C > > On 11/07/2011 01:39, James Newton wrote: > =20 >> Oh please.. I am REALLY not up for the C vs ASM debate. Please go play >> =20 > with > =20 >> your toys and leave this discussion to the adults? >> >> =20 > > I'd use C in preference to ASM any day. I wasn't at all suggesting ASM.=20 > Just sounding a warning. > > Really I don't believe in ASM except for some inline use or very small=20 > project. > > There is no need to be rude. Macro misuse is one of the biggest source=20 > of bugs in C programs. Not checking string real size and only relying on= =20 > Null termination is the other. > =20 --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .