Handling Files with Multiple Units (GNAT User’s Guide for Native Platforms)

#### 3.3.6.1 Handling Files with Multiple Units ¶

GNAT’s fundamental compilation model requires that a file submitted to the compiler contain only one unit and there be a strict correspondence between the file name and the unit name.

If you want to have your files contain multiple units, perhaps to maintain compatibility with some other Ada compilation system, you can use `gnatname` to generate or update your project files, which can be processed by GNAT.

See Handling Arbitrary File Naming Conventions with gnatname for more details on how to use gnatname.

Alternatively, if you want to permanently restructure a set of ‘foreign’ files so that they match the GNAT rules, and do the remaining development using the GNAT structure, you can simply use `gnatchop` once, generate the new set of files containing only one unit per file, and work with them from that point on.

Note that if your file containing multiple units starts with a byte order mark (BOM) specifying UTF-8 encoding, each file generated by gnatchop will start with a copy of this BOM, meaning that they can be compiled automatically in UTF-8 mode without you needing to specify an explicit encoding.