The documentation for pragma Source_File_Name
says the syntax is
pragma Source_File_Name (
[Unit_Name =>] unit_NAME,
Spec_File_Name => STRING_LITERAL,
[Index => INTEGER_LITERAL]);
pragma Source_File_Name (
[Unit_Name =>] unit_NAME,
Body_File_Name => STRING_LITERAL,
[Index => INTEGER_LITERAL]);
so the reason the compiler is complaining is that you've used incorrect syntax. Using the correct syntax, that would be
package Parent_With_Very_Long_Name.Child is
pragma Source_File_Name
(Parent_With_Very_Long_Name.Child, Spec_File_Name => "parent-child.ads");
end Parent_With_Very_Long_Name.Child;
but the compiler now says
parent-child.ads:2:01: incorrect placement for configuration pragma "Source_File_Name"
The proper placement for this configuration pragma is before the unit:
pragma Source_File_Name
(Parent_With_Very_Long_Name.Child, Spec_File_Name => "parent-child.ads");
package Parent_With_Very_Long_Name.Child is
end Parent_With_Very_Long_Name.Child;
which is all very well, but how are other units going to know this? (GNAT has a source-based compilation model). One answer is to put the pragma in a configuration file, gnat.adc
by default. A better answer is to use GNAT project files and package Naming
, as suggested by Jacob Sparre Andersen.