Using Other File Names (GNAT User’s Guide for Native Platforms)

#### 3.3.2 Using Other File Names ¶

The previous section described the default rules used by GNAT to determine the file name in which a given unit resides. It is usually convenient to follow these default rules, and if you follow them, 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 you to specify which file names contain which units. GNAT allows arbitrary file names to be used by means of 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 has the form of a named association. The identifier indicates whether the file name is for a spec or a body; the file name itself is given by a string literal.

The source file name pragma is a configuration pragma, which means that normally you will place it in the `gnat.adc` file used to hold configuration pragmas that apply to a complete compilation environment. For more details on how the `gnat.adc` file is created and used see Handling of Configuration Pragmas.

GNAT allows you to specify completely arbitrary file names using the source file name pragma. However, if the file name specified has an extension other than `.ads` or `.adb` you must use a special syntax when compiling the file. The name on the command line in this case must be preceded by the special sequence `-x` followed by a space and the name of the language, here `ada`, as in:

    $ gcc -c -x ada peculiar_file_name.sim

`gnatmake` handles non-standard file names in the usual manner (the non-standard file name for the main program is simply used as the argument to `gnatmake`). Note that if the extension is also non-standard, you must include it in the `gnatmake` command; it may not be omitted.