Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8591479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:32:16+00:00 2026-06-11T23:32:16+00:00

Using the GNAT compiler, when I try to compile or check semantic on the

  • 0

Using the GNAT compiler, when I try to compile or check semantic on the following files, I get some variation of the error package "Foo" does not allow a body. I’m new to the language and can’t find an answer to this seemingly basic problem anywhere on the Internet. Please advise.

foo.ads

package Foo is
   type Shape_Enum is (Circle, Triangle, Rectangle);
end Foo;

foo.adb

package body Foo is
   procedure Foo is
      MyShape : Shape_Enum;
   begin
      MyShape := Rectangle;
   end Foo;   
end Foo;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:32:18+00:00Added an answer on June 11, 2026 at 11:32 pm

    A package is only allowed to have a body if the specification includes something that requires a body. (This avoid problems where an optional body might accidentally be left out of a build.)

    You have a procedure in the body of the package (Foo.Foo), but there’s no way to call it.

    If you add a declaration:

    procedure Foo;
    

    to the specification, that should (a) fix the error, and (b) permit the procedure to be called by clients of the package. Or you can use pragma Elaborate_Body; to require it to have a body if you don’t want the procedure to be visible to clients.

    Incidentally, there’s nothing special about a procedure with the same name as the package that contains it (unlike in C++, where such a function is a constructor for the containing class). It would probably be clearer to use a different name.

    See section 7.2 of the Ada Reference Manual (I’m using a recent draft of the 2012 standard):

    A package_body shall be the completion of a previous
    package_declaration or generic_package_declaration. A library
    package_declaration or library generic_package_declaration shall not
    have a body unless it requires a body; pragma Elaborate_Body can be
    used to require a library_unit_declaration to have a body (see 10.2.1)
    if it would not otherwise require one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using GNAT Programming Studio to update some ada files. I have a style
I'm using Gnat (old compiler of ada95) and I'm having problem to print the
I have compiled an Ada program on Ubuntu using GNAT. Afterwards, I tried a
Using the Redis info command, I am able to get all the stats of
Using Location.getBearing(); I seem to get randomly changing bearings. Aka, I can turn the
Using Qt Creator, I have set a QWidget's background property to black. However, some
Using CMake I want to check if a particular function (cv::getGaborKernel) from OpenCV library
Using batch script, I want to get a first token of a line delimited
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using the Exiv2 library to write some exif tags to an image i'm running

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.