comp.lang.ada
 help / color / mirror / Atom feed
* Package spec and body in C.
@ 1997-09-25  0:00 J. M. Rayas
  1997-09-26  0:00 ` Ron Thompson
  1997-09-29  0:00 ` Eric W. Nikitin
  0 siblings, 2 replies; 4+ messages in thread
From: J. M. Rayas @ 1997-09-25  0:00 UTC (permalink / raw)



Hi all,

 I've been using Ada exclusively for the last 8 years, and I now
 have to develop some embedded software in C (I went down kicking 
 and screaming).

 Anyway, I would like to mimic Ada's package spec/body mechanism in C.
 If anyone has done this and/or has any info that they would like to
 share, it would be appreciated.


 Thanks.
-- 

+--------------------------+---------------------------+
|      Juan M. Rayas       | Jet Propulsion Laboratory |
|     Team-Ada Member      |    4800 Oak Grove Drive   |
| Flight Software Engineer |     Pasadena CA, 91109    |
+--------------------------+---------------------------+
|           E-mail: Juan.M.Rayas@jpl.nasa.gov          |
+------------------------------------------------------+




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Package spec and body in C.
  1997-09-25  0:00 Package spec and body in C J. M. Rayas
@ 1997-09-26  0:00 ` Ron Thompson
  1997-09-30  0:00   ` Simon Wright
  1997-09-29  0:00 ` Eric W. Nikitin
  1 sibling, 1 reply; 4+ messages in thread
From: Ron Thompson @ 1997-09-26  0:00 UTC (permalink / raw)



J. M. Rayas wrote:
> 
>  Anyway, I would like to mimic Ada's package spec/body mechanism in C.
>  If anyone has done this and/or has any info that they would like to
>  share, it would be appreciated.
> 

I have done this to a variety of degrees.  The main trick is to have
each header(.h) declare itself first thing.  That way other headers
and bodies can simply ask 
if(!thing_declared)
	#include thing.h;

The c compilers of my experience have difficulty with multiple
declarations of an interface, that is, they will continue to insert
the text of that header at the include point.  Ada will allow one to
with a spec multiple times.

Making null return functions so they look like procedures is another
need.

Using pointers as "in out" or "out" parameters is yet another tricky
matter, but doable.

Just a couple of rusty pennies from a lone Ada programmer.
-- 

rct

The opinions above are mine and mine alone.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Package spec and body in C.
  1997-09-25  0:00 Package spec and body in C J. M. Rayas
  1997-09-26  0:00 ` Ron Thompson
@ 1997-09-29  0:00 ` Eric W. Nikitin
  1 sibling, 0 replies; 4+ messages in thread
From: Eric W. Nikitin @ 1997-09-29  0:00 UTC (permalink / raw)



J. M. Rayas (Juan.M.Rayas@jpl.nasa.gov) wrote:
:  Anyway, I would like to mimic Ada's package spec/body mechanism in C.
:  If anyone has done this and/or has any info that they would like to
:  share, it would be appreciated.

A number of months ago, I looked briefly at the book _C Interfaces and
Implementations_ by David R. Hanson (ISBN 0-201-49841-3).  It may be
what you're looking for.  There is a web link with more info and stuff
to download at

	http://www.cs.princeton.edu/software/cii/

-- 
Eric
---




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Package spec and body in C.
  1997-09-26  0:00 ` Ron Thompson
@ 1997-09-30  0:00   ` Simon Wright
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Wright @ 1997-09-30  0:00 UTC (permalink / raw)



Ron Thompson <thompsor@admin.tc.faa.gov> writes:

> J. M. Rayas wrote:
> I have done this to a variety of degrees.  The main trick is to have
> each header(.h) declare itself first thing.  That way other headers
> and bodies can simply ask 
> if(!thing_declared)
> 	#include thing.h;

The normal technique for this is to put the condition in the header
file (that stops the user having to worry about getting it right):

/* foo.h */
#ifndef __FOO_H__
#define __FOO_H__
...stuff...
#endif /* __FOO_H__ */

(actually, there are some rules to do with reserved names (names
starting with an underscore and a capital letter, or starting with
double underscore being reserved: I guess I should change to eg
_foo_h_ or something like that.)

-- 
Simon Wright                        Work Email: simon.j.wright@gecm.com
GEC-Marconi Radar & Defence Systems            Voice: +44(0)1705-701778
Command & Information Systems Divsion            FAX: +44(0)1705-701800




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1997-09-30  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-09-25  0:00 Package spec and body in C J. M. Rayas
1997-09-26  0:00 ` Ron Thompson
1997-09-30  0:00   ` Simon Wright
1997-09-29  0:00 ` Eric W. Nikitin

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