For any program which does any form of file I/O, the following needs to be done:
- For each FILE declaration it must have storage allocated to its FILE constant. This is achieved through the use of the -defext compile option and/or through the use of an optional parameter called GLOBALDEF. It is important that within a fetchable procedure or a program compiled with OPTIONS(MAIN), this is done exactly one time per FILE constant. If this is not done, the results are completely unpredictable and the behaviors will not be supported.
- For typical usage, compiling with -defext is more than adequate. If you have two or more subroutines which are all accessing the same FILE constant, and they are linked into a single fetchable procedure or program, only one of the programs should be compiled with -defext. As an alternative approach you can add the attribute GLOBALDEF to one of the file declarations and not use the -defext switch for any of the compiles.