comp.lang.ada
 help / color / mirror / Atom feed
* simple question - how to emulate void * ?
@ 1998-10-23  0:00 Craig Allen
  1998-10-23  0:00 ` Tom Moran
                   ` (3 more replies)
  0 siblings, 4 replies; 24+ messages in thread
From: Craig Allen @ 1998-10-23  0:00 UTC (permalink / raw)


Well, yes, I'm new to ada, and coming from C.

Now, I have some simple functionality that I'd like to see, and can't 
figure out how to do it in Ada.

in C, it goes like this:

/* libfile.c */

void print_bytes(void *buf, int len)
{
	int i;
	char *c = buf;
	for (i=0; i<len; ++i) {
		putchar(c[i]);
	}

	return;
}

/* app.c */
	...
	struct any_struct data;
	print_bytes(&data, sizeof (struct data));
	...

The lib can access byte for byte the data passed in regardless of the 
app's struct type.  Now, Ada being such a strongly typed language, I 
have tried different things but just can't seem to figure out how to 
get this lib routine to work on my buffer, regardless of its type.  
I've come close with some generic functions, but can't seem to get the
syntax acceptable for the compiler.
Can someone point me in the right direction?

Specifically, this library function will be shipping things out a 
serial port, one byte at a time, that is why i'd like to address it as
an array of bytes.

Thanks.
-Craig




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

end of thread, other threads:[~1998-11-06  0:00 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-23  0:00 simple question - how to emulate void * ? Craig Allen
1998-10-23  0:00 ` Tom Moran
1998-10-23  0:00 ` Dale Stanbrough
1998-10-22  0:00   ` Hans Marqvardsen
1998-10-23  0:00     ` John McCabe
1998-10-23  0:00       ` dennison
1998-10-23  0:00       ` Ed Falis
1998-10-23  0:00         ` dennison
1998-10-24  0:00           ` Joe Wisniewski
1998-10-25  0:00           ` dewar
1998-10-24  0:00         ` Dale Stanbrough
1998-10-24  0:00           ` Robert A Duff
1998-10-24  0:00           ` Tucker Taft
1998-10-22  0:00   ` Hans Marqvardsen
1998-10-23  0:00   ` David C. Hoos, Sr.
1998-10-23  0:00   ` David C. Hoos, Sr.
1998-10-23  0:00 ` Jeff Carter
1998-10-24  0:00   ` Dale Stanbrough
1998-10-25  0:00     ` dewar
1998-11-05  0:00 ` Craig Allen
1998-11-06  0:00   ` Dale Stanbrough
1998-11-06  0:00     ` Matthew Heaney
1998-11-06  0:00       ` dewarr
1998-11-06  0:00   ` Tom Moran

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