A.4. Using Other File Names

In the previous section, we have described the default rules used by XGC Ada to determine the file name in which a given unit resides. It is often convenient to follow these default rules, and if you do then the compiler knows without being explicitly told where to find all the files it needs.

However, in some cases, particularly when a program is imported from another Ada compiler environment, it may be more convenient for the programmer to specify which file names are used. XGC Ada allows arbitrary file names to be used via the Source_File_Name pragma. The form of this pragma is as shown in the following examples:


pragma Source_File_Name (My_Utilities.Stacks,
  Spec_File_Name => "myutilst_a.ada");
pragma Source_File_name (My_Utilities.Stacks,
  Body_File_Name => "myutilst.ada");

As shown in this example, the first argument for the pragma is the unit name (in this example a child unit). The second argument must have an identifier which indicates if the file name is for the spec or the body, and the file name itself is given as a static string constant.

The source file name pragma is a configuration pragma, which means that normally it will be placed in the gnat.adc file used to hold configuration pragmas that apply to a complete compilation environment. See Appendix B for more details on how the gnat.adc file is created and used. XGC Ada allows completely arbitrary file names to be specified using the source file name pragma. However, if the file name specified has an extension other than .ads .adb or .ada it is necessary to use a special syntax when compiling the file. The name in this case must be preceded by the special sequence -x followed by a space, as in:


$ prefix-gcc -c -x peculiar_file_name.sim

If gnatmake is used, then it handles non standard file names automatically. One special case arises if the main unit has a non-standard file name, in this case, the gnatmake argument must be this non-standard file name. It is not possible to use the normal unit name form of the gnatmake command in this case.