Mark Nudelman wrote:
> 
> Alex Robinson wrote:
> > Over that last few years I've changed my own code to "opaque" pointers.
> > That is, the .H file contains something like this:
> >
> > typedef struct {
> >         Byte    dummy;
> >         } A_THANG;
> >
> > And the .C file does this:
> >
> > typedef struct {
> >         int     real_stuff;
> >         long    more_stuff;
> >         Byte    etc;
> >         } A_THANG;
> >
> 
> I use something similar to get opaque pointers:
> 
> In the public .h file I have
>         typedef struct A_THANG A_THANG;
> 
> And in the .c file (or a private .h file):
>         struct A_THANG {
>                 int real_stuff;
>                 ...etc...
>         };
> 
> Then clients who include the public file can use "A_THANG *" but cannot
> declare A_THANG variables directly, and cannot dereference A_THANG
> pointers.
> 
> --Mark

Chris Antos suggested the same in another message (lost to me 'cause
Win95 did it's thing). Some compilers complain about this simple
implementation. Other compilers complain about the code I gave, though.
I should have been clear that the code I gave was written only to
express the idea, not to show, exactly, how to do it. It was a mistake
to have thrown in the "dummy" - which, in fact, is part of the amazing
"incantations" needed to get all of the compilers that I've run in to to
handle this technique.

By the way, I *so* agree with Chris that if the compiler doesn't enforce
it, it's suspect (or bad). That's why I don't like Hungarian and too
many in-line comments. The former relies on our ability to write
bug-free, uncompiled code. (*I* can, of course, and, by golly, I'll
*show* you as soon as I write my first computer program.) The latter
makes it hard to see the actual, real, code.

Ahhh. Stop it, Alex! Enough of this thread! Say, a question: belief in
what religion helps one write the tightest code? :)

Alex Robinson
[EMAIL PROTECTED]

-eom-

Reply via email to