Search code examples
packageadacompilationunit

Ada, check out my package. ("compilation unit expected"?)


I've gotten rid of all my other compile-time errors except "compilation unit expected", which starts right after my import statements. I'm guessing I need to create a package? And if so, how do I do it? I have a few functions all living in the same .ADB file.

EDIT: So I gave it a shot...

Check out my package:

-- Import Statements
with Ada.Text_Io;
use Ada.Text_Io;

package body MyPackage is

-- Declarations
-- Functions

end MyPackage;

But gcc screams when it sees MyPackage:

a_.adb:27:18: loop or block statement must follow label
a_.adb:27:18: reserved word "array" cannot be used as identifier
a_.adb:28:01: declarations must come before "begin"

Maximus graCimuS


Solution

  • Those compiler messages can't belong to the code you posted (because it doesn't have 28 lines).

    In any case, GCC will expect this code to be in a file mypackage.adb; and will require there to be a package spec in mypackage.ads.