comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: .h header file in ObjectAda 8.2.2 source code?
Date: Fri, 19 Jul 2013 16:02:56 +0300
Date: 2013-07-19T16:02:56+03:00	[thread overview]
Message-ID: <b4sro0FqrliU1@mid.individual.net> (raw)
In-Reply-To: <54f7f0d4-29ef-4de0-94d8-8320e8df24e2@googlegroups.com>

On 13-07-19 14:47 , dd24fan wrote:
> Hi, all! I currently have this requirement to include a .h file in
> the ObjectAda source code.  I'm not quite sure how to do this.

That depends on what the .h file contains... in C, it can contain any
kind of C code. I've seen C programs in which the .h files contain large
chunks of executable code, both in macros and in real functions.
(Perhaps that C programmer thought that only .h files can be #included.)

> Is this done by pragmas?

Yes, for some .h information. Other information, such as type
declarations, must be translated into ordinary Ada code (Ada type
declarations), i.e. not (only) pragmas.

Can you show us the .h file, or some of the parts of it that you are using?

> Btw, in my source code now I've referenced
> all the functions needed to communicate with the hardware via pragma
> imports.

That is the right way, for functions that are declared in the .h file
and then called from the Ada code. Note that in addition to the Import
pragmas for the functions, the parameter types may need Convention
pragmas to make the Ada compiler follow C memory structures.

Can you show an example of a C function declared in the .h file, and
your corresponding Ada function (declaration)?

> I've also included the .lib file the vendor suggests in my
> project.

Sounds like a necessary thing, although I don't know the details of how
C libraries are included in ObjectAda programs.

> When i try to run the executable in my test environment the .exe just
> hangs.  Any insight would be greatly appreciated.

Not enough information... Where does it hang? Is any part of the Ada
main subprogram executed? Does it hang in the first call to the C code?

You speak of "communicating with hardware". Are special drivers
involved? Does the C code use interrupts? Does the program run on a
PC/Windows/Linux, or on an embedded bare-board system? Can you step
through the code with a debugger?

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
      .      @       .


  reply	other threads:[~2013-07-19 13:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-19 11:47 .h header file in ObjectAda 8.2.2 source code? dd24fan
2013-07-19 13:02 ` Niklas Holsti [this message]
2013-07-19 15:36 ` dd24fan
2013-07-20  5:41   ` Randy Brukardt
2013-07-22 19:06     ` dd24fan
2013-07-22 19:08     ` dd24fan
2013-07-22 20:04       ` Niklas Holsti
2013-07-23 12:05         ` dd24fan
2013-07-22 19:50     ` dd24fan
2013-07-20  8:07   ` Niklas Holsti
2013-08-01 15:03     ` Stephen Leake
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox