home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!destroyer!cs.ubc.ca!unixg.ubc.ca!sitka.triumf.ca!morgan
- From: morgan@sitka.triumf.ca (Morgan Burke)
- Newsgroups: comp.lang.fortran
- Subject: Re: Multiple includes
- Date: 11 Nov 1992 00:58:35 GMT
- Organization: TRIUMF, Vancouver BC
- Lines: 30
- Distribution: world
- Message-ID: <1dplrrINNg7t@iskut.ucs.ubc.ca>
- References: <1dotfaINN4a1@alnitak.usc.edu>
- NNTP-Posting-Host: sitka.triumf.ca
-
- In article <1dotfaINN4a1@alnitak.usc.edu>, olaf@alnitak.usc.edu (Olaf Meeuwissen) writes:
- |> Is there a way to include files conditionally?
- |> I mean, only include it if it is not included already.
-
- If your f77 compiler uses cpp, you can use the #include statement
- instead of the Fortran INCLUDE. Then, inside the include file, use
- #define and #ifndef, for example:
-
- C dim.h
- #ifndef INCLUDE_DIM
- INTEGER dim
- PARAMETER ( dim = 10 )
- #endif
- #define INCLUDE_DIM
- C end of dim.h
-
- The file will be included more than once, but the contents will only be
- present the first time it is included.
-
- Of course, if you are going to use cpp anyway, you could always just do:
-
- C dim.h
- #define DIM 10
- C end of dim.h
-
- and then declare all your arrays with dimension DIM. It won't matter if
- this file is included more than once.
-
- -- Morgan Burke (morgan@reg.triumf.ca)
-
-