portability/maintenance

Stephen J Bevan bevan at cs.man.ac.uk
Wed May 30 03:20:35 AEST 1990


Some months ago, I think someone asked a question about tips on
writing portable programs.  Numerous people answered and a summary
was produced.

One suggestion was that for large projects (don't ask me to define
large) a set of standards be drawn up before you start i.e. what
the indentation style is, where the comments go etc.  These were
the sort of things I expected to see.

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

bevan at cs.man.ac.uk



More information about the Comp.lang.c mailing list