× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Frank,

Here is a discussion on the topic:

http://stackoverflow.com/questions/14041453/why-are-preprocessor-macros-evil-and-what-are-the-alternatives

HTH,

Marc


On 4/4/2014 1:24 AM, Frank Kolmann wrote:
Hi Barbara



Thank you for your comments. I am happy to start a discussion on macros.

Please understand I value and appreciate your comments.

Couple of points.



I found the 'forever' macro in this book. pp97



The C programming Language

By Brian W. Kernighan and Dennis M. Ritchie.

Published by Prentice-Hall in 1988

ISBN 0-13-110362-8 (paperback)

ISBN 0-13-110370-9

-- exerpt --

Any name may be defined with any replacement text. For
example

#define forever for (;;) /* infinite loop */

defines a new word, forever, for an infinite loop.



Do you mean to say that the C gods K&R themselves published weird code?



Also if C programmers cannot cope with macros does not that imply they

are not truly C programmers.



Why does C have the ability to have such marco substitution if it is

not to be used.

Particularly if it helps avoid a potential bug that the compiler

does not report and only manifests at execution time (= for ==).



I believe I will have no problem interpreting the standard C

code or other C code with macros.



Frank





*Subject: Re: First C Program
*From: Barbara Morris <bmorris@xxxxxxxxxx>
*Date: Thu, 03 Apr 2014 13:42:13 -0400
Hi Frank, I have been thinking about the use of macros such as
EQ, forever, NE etc, and I think you are doing yourself a disservice
by using these macros as a beginner C programmer. Here are some of the
reasons:

You will find it less easy to read "normal" C code if you don't get
used to seeing *and quickly interpreting* things like != == for(;;)
You will find it more difficult to incorporate code that you find on the
web.

You will have to either change all the == and != to use your macros,
or perhaps even worse, you will have a mixture of EQ and ==.
You will not be able to post snippets of code to forums without
replacing your macros. I wouldn't post weird code like that to any forum
even with an explanation for what the macros mean.
The discussion would almost certainly be more about the use of the macros
than about whatever question you were trying to ask.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.