| Version 1.9 Build 1556
|
|
Next: Fundamental Types
Up: Coding Fundamentals
Previous: Compilers
All files should should ensure that <aips/aips.h> is included in
their source file. It currently makes sure the following are properly
defined:
- 1.
- #pragmas that are required for the TI preprocessor (presently
used to implement templates () and run time type
identification ().
- 2.
- It will make some portability adjustments and ensure that fundamental
types () are available.
- 3.
- Ensure that the namespace management () is
turned on.
- 4.
- And any other miscellaneous things that are required to ensure that
programmers can see a common environment.
Some other include files that are of general note are:
- aips/aips_exit.h
If you are having name conflicts with another library you can include
this file and refer to aips++ classes by their full name.
- aips/Constants.h
If you have a common mathematical constant it should be available in
here. If it isn't, please think about adding it. 3.1 This file should
also have astronomical and physical constants at some point. Don't hide
what might be generally useful constants in your code -- make them
generally available!
- aips/Error.h
If you intend to catch or throw any aips++ exceptions ()
you should include this file.
- aips/Math.h
You should include this file instead of #include <math.h> since
unfortunately math.h doesn't always have a uniform set of functions.
Also a few additional functions are in Math.h, in particular min
and max functions.
The strategy for including files is very important. Every file which is
#include'd in your .h file will normally
3.2 be opened and read in turn as your header
file is scanned, even if you have protected your header file
().
This can greatly increase your compilation time.
Instead of #include in your header files, you should instead
forward declare all the classes you need, and then do the #
include in your source (".C") file. The only times you might want to
violate this rule of thumb is when the classes you are defining in your
header file will always or almost always be used with another set of
classes, then for convenience you might want to package them together
this way. You might also be conservative and always include
aips/aips.h.
So, instead of:
#include <aips/Foo.h>
class Bar
{
Foo doit();
};
We would have:
class Foo; // Forward
class Bar
{
Foo doit();
};
Next: Fundamental Types
Up: Coding Fundamentals
Previous: Compilers
  Contents
  Index
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc.,
Washington, D.C.
Return to AIPS++ Home Page
2006-10-15