portability/maintenance

Mike McNelly mike at hpfcso.HP.COM
Fri Jun 1 01:45:22 AEST 1990


> ...
> Another suggestion, however, was to use dummy macros to help make
> the type and purpose of parameters and functions stand out.  For
> example, you would have a header file containing the following
> sort of definitions (the rest of this is in K&R I C, I haven't
> really got into the swing of ANSI C yet) :-
> 
> #define PUBLIC
> #define INOUT
> #define IN
> #define PRIVATE static
> #define FORWARD extern
> 
> These would then be used in .c files to make functions look like :-
> 
> PUBLIC void some_function(anInt, aChar)
  > INOUT int *anInt;
  > IN char aChar;
> {
  > FORWARD another_function();
  > ...
> }
> 
> PRIVATE void another_function(aParam)
  > OUT int *aParam;
> {
  > ...
> }
> 
> What I'd like to know is do people acutally use this, and would
> they mind having to maintain code that was written this way?

> I've got to admit I kind of like the idea, but if people are going
> to bitch about the code if its written in this style, then I'd
> rather not use it.
> 
> As a final point, if you think its an ok idea, do you still think
> its ok if the macros were changed to lower case?  (I guess the
> answer to this will be no, its just that I really hate UPPER CASE)
> 
> Stephen J. Bevan

This is all religion so don't be too surprised if you get diverse,
argumentative responses.  However, here's a personal view.

We've used

# ifdef DEBUGGING
#	define LOCAL
# else	/* DEBUGGING */
#	define LOCAL static
# endif	/* DEBUGGING */

for years as a construct in our headers because it simplifies use of the
symbolic debugger during development (static vars normally don't have
full information in the a.out file).

Personally I don't get too excited about dummy defines one way or the
other but they do seem to be an attempt to provide useful information.
My preference is to make all macros uppercase just so I know that
they're macros and not functions (it does make a difference, of course).
Some of my collegues like mixed case identifiers as a byzantine method
of encoding all sorts of information (much like your dummy macros above)
but this just seems to get in the way of my poor typing skills.

Mike McNelly
mike%hpfcla at hplabs.hp.com



More information about the Comp.lang.c mailing list