This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Use of VLA in struct in gcc-torture/execute/20020412-1.c


On 09-Sep-2002, John David Anglin <dave@hiauly1.hia.nrc.ca> wrote:
> I still don't understand the function of empty structs.

They can be useful with conditional compilation, e.g.

	struct OS_Stuff {
		#ifdef __linux
			...
		#endif
	};

They're also sometimes useful for abstraction -- you may have cases
where a particular subcomponent doesn't need any state in its current
implementation, but you can think of alternative implementations which
would need to retain state.  In that case, you can use an opaque struct
type to hide the implementation details, and then implement the opaque
struct as an empty struct.

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]