Path: csiph.com!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: Effect of CPP tags Date: Mon, 08 Jan 2024 22:56:00 -0800 Organization: A noiseless patient Spider Lines: 28 Message-ID: <86ederm1vj.fsf@linuxsc.com> References: <%cFlN.140487$xHn7.115393@fx14.iad> <87wmsns8by.fsf@nosuchdomain.example.com> <87sf3brzs5.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: dont-email.me; posting-host="c1b5d5e1dc8791530bc9d070ed4e4ac0"; logging-data="2029596"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18hHM0T1pTvKVCE9jsq+fEuTagkXvo+ww0=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:e7AwWZesi5+/wT7Ad4eaUSCHk8A= sha1:MVfT0VZO6udLn1iXBjGG02jwczI= Xref: csiph.com comp.lang.c:379943 scott@slp53.sl.home (Scott Lurndal) writes: [..concerning using a macro to determine the number of elements in an array, eg #define ARRAY_SIZE(a) (sizeof (a) / sizeof (a)[0]) ] > Indeed. I do believe that absent standardization, using a macro > adds a level of indirection that may adversely affect the code > readability (whether it is ARRAY_SIZE, ARRAY_LENGTH, LENGTH, NUM_ELEMENTS, > or whatever, I would need to refer to the macro definition to > determine the intent of the programmer). This reaction strikes me as being a bit nutty. I don't insist that a macro be used in such cases, but I wouldn't object to it either. It's much like the question of whether to wrap up several statements in a separate function definition, or simply write them inline. It's almost always true that either choice is acceptable, depending on what the author wants to emphasize. There are pluses and minuses on both sides. There are situations for which using a macro rather than writing out the code directly nearly always has a predominately negative effect, but this case isn't one of them. (To be clear, all of the above simply statements of my own opinions.)