Is this legal ?

S

Sjouke Burry

Spiros said:
jacob navia wrote:




lcc will accept which code ? How are you going to
refer to members ? Examples please.
Like we have done for years,just do not
use conflicting names, and it works fine
(for some compilers, like MS,watcom,bc,tc....)
 
K

Keith Thompson

jacob navia said:
Well I could add a

-pedantic

flag like another well known compiler...

Maybe that is the solution. You would have

-ansic (conforming except _stdcall and anonymous structures)

-pedantic (100% heathfield compatible)

Yes, you could. But since such a mode would conform to the ISO C
standard, not to anything having directly to do with Mr. Heathfield,
your "100% heathfield compatible" remark is gratuitous and insulting.
 
S

Spiros Bousbouras

Sjouke said:
Like we have done for years,just do not
use conflicting names, and it works fine
(for some compilers, like MS,watcom,bc,tc....)

Who's "we" ? It's not something *I* would do because
to have at several places in my code something like
str_name.field_name when in reality it's
str_name....intermediate_stuff...field_name sounds like
flirting with disaster. If I wanted to save keystrokes I
would either use vim's abbreviations feature or assign
the field values I'm interested in to temporary variables.
 
J

jacob navia

Spiros said:
Sjouke Burry wrote:




Who's "we" ? It's not something *I* would do because
to have at several places in my code something like
str_name.field_name when in reality it's
str_name....intermediate_stuff...field_name sounds like
flirting with disaster. If I wanted to save keystrokes I
would either use vim's abbreviations feature or assign
the field values I'm interested in to temporary variables.

It is not to save keystrokes. It is for giving you the
flexibility of changing the "inheritance" path as requirements
change.

instead of
CustomerInfo->struct_a->struct_b->struct_c->CustomerBalance

you write
CustomerInfo->CustomerBalance

and you are free to REARRANGE the intermediate structures as you wish,
and as changing requirements need.
 
K

Keith Thompson

jacob navia said:
It is not to save keystrokes. It is for giving you the
flexibility of changing the "inheritance" path as requirements
change.

instead of
CustomerInfo->struct_a->struct_b->struct_c->CustomerBalance

you write
CustomerInfo->CustomerBalance

and you are free to REARRANGE the intermediate structures as you wish,
and as changing requirements need.

Great. I'm very happy that you're able to do this in your own
language. It cannot be done in standard C which, for the Nth time, is
what we discuss in this newsgroup. As you know perfectly well.
 
K

Kenneth Brody

jacob navia wrote:
[...]
It is not to save keystrokes. It is for giving you the
flexibility of changing the "inheritance" path as requirements
change.

instead of
CustomerInfo->struct_a->struct_b->struct_c->CustomerBalance

you write
CustomerInfo->CustomerBalance

and you are free to REARRANGE the intermediate structures as you wish,
and as changing requirements need.

At the expense of maintainability, as you have hidden what, and where,
CustomerBalance is. I'd hate to have to search through who knows how
many header files, hoping to track down the path to CustomerBalance.

And, what happens when some structure, which is contained in some
structure, which is pointed to by another structure within CustomerInfo
adds a pointer to a structure which contains a pointer to a structure
which has a CustomerBalance member?

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:[email protected]>
 
J

Jack Klein

The main usage of Annonymous Union is to limit scope of some name
space. If you are defining Anno. union, you have to take care scope of
variable yourself.

There is no "main use" of anonymous unions in C, because there are no
anonymous unions in C. Not at all. Period.

If you have a compiler that accepts this, either it is not a C
compiler, or perhaps it is not being invoked in a manner that would
cause it to be a C compiler.
 
G

Guest

Jack said:
There is no "main use" of anonymous unions in C, because there are no
anonymous unions in C. Not at all. Period.

If you have a compiler that accepts this, either it is not a C
compiler, or perhaps it is not being invoked in a manner that would
cause it to be a C compiler.

Or it is a C compiler supporting anonymous unions as an extension. As
long as a diagnostic is issued, there is no problem. This diagnostic
may be an error, a warning, a notice, a remark, or almost anything
else, and the standard does not require implementations to refuse to
translate any program (with an exception for #error).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,434
Messages
2,571,689
Members
48,796
Latest member
Greg L.

Latest Threads

Top