[LC++]Producing a log of routine entry and exit
Dr Mark H Phillips
mark at austrics.com.au
Wed Sep 4 15:26:11 UTC 2002
On Fri, 2002-08-30 at 21:21, Carlo Wood wrote:
> > "Any project should have one header file that is included at the top of
> > every source file. If you already have one then you can add #include
> > <libcw/sysd.h> to that file. Otherwise you should add such a header
> > file: its a Good Thing(tm) to have."
> >
> > Am I right in thinking this is something you wrote? If so, could you
> > please explain the reasons why it is a "Good Thing(tm)".
>
> Out of many many years of experience.
>
> It turns out that often you need something that is not
> directly related to your application but has external
> reasons. The most common reason is porting (differences
> between OS). It is a Good Thing to have those things
> at one place, in one header file - so it stays maintainable
> and surveyable. Code duplication is bad in general :).
> Furthermore it turns out having this header _standard_
> at the *start* of each source file, before ANY system
> header file is included, gives you much more power to
> use it for Operating System differences.
>
> Finally, there is no good reason not to do it :p.
> Just like adding a license header to each file,
> and
>
> #ifndef MYAPP_HEADENAME_H
> #define MYAPP_HEADENAME_H
>
> ...
>
> #endif // MYAPP_HEADENAME_H
Thanks for this explanation!
Just a couple of minor questions. Is "sys.h" the best
name for this file? Ie, couldn't it be confused with
/usr/include/linux/sys.h? Perhaps "umbrella.h" would be
a better name? But on the other hand, maybe "sys.h"
is the psuedo standard name for it???
The other minor question is... Is there any particular advantage
in using
> #ifndef MYAPP_HEADENAME_H
> #define MYAPP_HEADENAME_H
rather than just
#ifndef HEADERNAME_H
#define HEADERNAME_H
I guess it means it makes it clear which project the header is
associated with. But why not do the same with the filename? Eg
you could have "myapp_sys.h".
Anyway, I'm just a bit curious about what "useful conventions" are
out there that I don't know about, or realize the advantages of.
Thanks again for your help.
Cheers,
Mark.
--
Dr Mark H Phillips
Research Analyst (Mathematician)
AUSTRICS - smarter scheduling solutions - www.austrics.com
Level 2, 50 Pirie Street, Adelaide SA 5000, Australia
Phone +61 8 8226 9850
Fax +61 8 8231 4821
Email mark at austrics.com.au
More information about the tuxCPProgramming
mailing list