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 7910575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:54:45+00:00 2026-06-03T12:54:45+00:00

I would like to declare some user-defined compiler-constants to keep my specification files as

  • 0

I would like to declare some “user-defined compiler-constants” to keep my specification files as “constant” as possible. This is something common in C++, e.g. :

// misc/config.hh
namespace misc
{
  typedef std::shared_ptr<A> A_ptr; 
  namespace arch = ibmpc;
}

// misc/code.hh
#include "misc/config.hh"
namespace misc
{
  void function p(A_ptr a);
}

Which would be in Ada :

-- misc.ads
package Misc is
  use Types; ----> forbidden !

  procedure P(A : A_Access);
end Misc;

-- misc-types.ads
package Misc.Types is
  type A_Access is A'Access;
end Misc.Types;

Of course this does not work since use is a context keyword…hence my question : how is it possible to do something with the same results in Ada ?

  • 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-03T12:54:46+00:00Added an answer on June 3, 2026 at 12:54 pm

    I think this is a reasonable mapping from your C++ original to Ada:

    To start with, corresponding more-or-less, I think, to your namespace misc, in file misc.ads,

    package Misc is
    end Misc;
    

    Then, corresponding to config.hh, in file misc-config.ads,

    package Misc.Config is
       type A is (For_Example, An_Enumeration);
       type A_Access is access A;
    end Misc.Config;
    

    (which could, of course, also reference types in Misc). Then, corresponding to code.hh, in file misc-code.ads,

    with Misc.Config;
    package Misc.Code is
       use Config;
       procedure P (A : A_Access);
    end Misc.Code;
    

    Personally I wouldn’t use Config;, at any rate in specs – it can make it difficult to work out where something is defined. Note, you can say use Config; or use Misc.Config; where shown, because you’re in a child of Misc; in the context clause, which is also OK, you would have to use Misc.Config;.

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

Sidebar

Related Questions

I would like to declare some integer constants in PowerShell. Is there any good
I would like to add some constant keys for my application, these constants can
I would like to know how do I declare a record, that has some
I would declare an empty String variable like this: string myString = string.Empty; Is
I have some logic, which defines and uses some user-defined types, like these: class
I would like to declare a record in Delphi that contains the same layout
I have written my own function, which in C would be declared like this,
I have defined an assembly level attribute class FooAttribute like this: namespace Bar {
If a user inserts rows into a table, i would like SQL Server to
What I have below is some notification code. What I would like to achieve

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.