External_Initialization Aspect (GNAT Reference Manual)

#### 17.3.10 External_Initialization Aspect ¶

The `External_Initialization` aspect provides a feature similar to Rust’s `include_bytes!` and to C23’s `#embed`. It has the effect of initializing an object with the contents of a file specified by a file path.

Only string objects and objects of type `Ada.Streams.Stream_Element_Array` can be subject to the `External_Initialization` aspect.

Example:

    with Ada.Streams;

    package P is
       S : constant String with External_Initialization => "foo.txt";

       X : constant Ada.Streams.Stream_Element_Array with External_Initialization => "bar.bin";
    end P;

`External_Initialization` aspect accepts the following parameters:

- mandatory `Path`: the path the compiler uses to access the binary resource.

If `Path` is a relative path, it is interpreted relatively to the directory of the file that contains the aspect specification.

Attention: The maximum size of loaded files is limited to 2^31 bytes.