[m-dev.] Changes to mercury/runtime

Fergus Henderson fjh at cs.mu.oz.au
Thu Feb 13 17:46:00 AEDT 1997


Bert Thompson, you wrote:
> 
> |Yes, I differ.  There is a significant difference in C between typedefs
> |and structs: you can forward declare a struct, but you can't forward
> |declare a typedef.  The capability to forward declare things can come
> |in useful sometimes, e.g. to avoid circular dependencies between header
> |files.
> 
> I don't understand what you mean. Can you provide a concrete example?

How about an abstract example:

	/* foo.h */
	struct foo_struct {
		struct bar_struct *p;
		...
	};
	#define FOO_SOMETHING ...

	/* bar.h */
	#include "foo.h"	/* for FOO_SOMETHING */
	struct bar_struct {
		...
	};
	#define BAR_STRUCT \
		... FOO_SOMETHING ...

If you don't use `struct bar_struct' in this example, then the
header files will need to be split up to avoid the circular dependency.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list