On Wed, Apr 17, 2013 at 09:38:08AM -0500, Greg London wrote: > > On Wed, Apr 17, 2013 at 09:29:34AM -0500, Greg London wrote: > >> > You can write macros that have varargs, > >> Dumb hardware engineer question: > >> Why use macros when you can write a function? > > In this very simple case it makes no significant difference. > When WOULD it make a difference?
I'm assuming that you want to use these macros/functions in more than one C file. Doing it as just a macro means writing and #include-ing one file and the job's done. Doing it as a function means that plus writing another C source file, plus frobbing your Makefile to make sure that it gets built and linked. If the benefits (in terms of making the code cleaner or more debuggable or whatever) outweigh the minor hassle involved, then I'd write a function. Incidentally, there is libtap, but I have no idea how complete and correct it is, and it appears to have not been updated for some time: http://jc.ngo.org.uk/trac-bin/trac.cgi/wiki/LibTap -- David Cantrell | semi-evolved ape-thing Eye have a spelling chequer / It came with my pea sea It planely marques four my revue / Miss Steaks eye kin knot sea. Eye strike a quay and type a word / And weight for it to say Weather eye am wrong oar write / It shows me strait a weigh. _______________________________________________ Boston-pm mailing list [email protected] http://mail.pm.org/mailman/listinfo/boston-pm

