🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by b91926 Mon, 25 Jan 1993 23:12
structs that define nothing
#1367
Author: b91926
Date: Mon, 25 Jan 1993 23:12
14 lines
708 bytes
Does the c++ standard have anything to say about the legality of a
construct like the following:

...
struct
{
  int a;
  int b;
};

...

Such an example appeared in a recent issue of "C++ Report". The
problem with this code is that it defines absolutely nothing.
Re: structs that define nothing
#1371
Author: Donald W. Rouse II
Date: Wed, 27 Jan 1993 17:33
34 lines
1383 bytes
In article <1993Jan25.171222.1@fnalng.fnal.gov> b91926@fnalng.fnal.gov writes:
>Does the c++ standard have anything to say about the legality of a
>construct like the following:
>
>...
>struct
>{
>  int a;
>  int b;
>};
>
>...
>
>Such an example appeared in a recent issue of "C++ Report". The
>problem with this code is that it defines absolutely nothing.

This example reminds me of a possible extension to C++ (and C)
that could occasionally be useful: anonymous structures,
which are analogous to anonymous unions.

Example:
	typedef union
		{
		unsigned long lw;
		struct { unsigned short sw0, sw1; };
		struct { unsigned char b0, b1, b2, b3; };
		}	machword;
	machword	r1, r2;

Now you can access r1.b2, instead of having to do
something like r1.b.b2, etc.

Note that the only place this would be useful
is inside a union.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads