Connecting Tech Pros Worldwide Help | Site Map

Re: A question of programming technique in C

Eric Sosman
Guest
 
Posts: n/a
#1: Nov 5 '08
Richard Harter wrote:
Quote:
On Tue, 04 Nov 2008 16:43:49 -0500, Eric Sosman
<Eric.Sosman@sun.comwrote:
Quote:
>>[...]
> But the "unrestricted access" issue is easily dealt with, in
>the sense that the contents can be made "opaque." The tradition-
>honored technique in C is for your "bobble.h" to omit any mention
>of the elements of a struct bobble_s. You can declare a function
>as accepting a struct bobble_s* as an argument or returning one
>as a result without revealing what a struct bobble_s looks like,
>or even revealing its size. See "incomplete type."
>
As it happens, I am quite familiar with the concept and the
technique, but I didn't mention it explicitly because I took it
for granted that bobble.h would provide an incomplete type. [...]
Your original message said
Quote:
we have definitions like
>
struct bobble_s {...};
>
in our bobble.h.
.... and the presence of `{...}' led me to believe you were
contemplating a complete struct declaration, elements and all.
What *did* you mean by `{...}'?

--
Eric Sosman
esosman@ieee-dot-org.invalid
Richard Harter
Guest
 
Posts: n/a
#2: Nov 5 '08

re: Re: A question of programming technique in C


On Wed, 05 Nov 2008 08:40:39 -0500, Eric Sosman
<esosman@ieee-dot-org.invalidwrote:
Quote:
>Richard Harter wrote:
Quote:
>On Tue, 04 Nov 2008 16:43:49 -0500, Eric Sosman
><Eric.Sosman@sun.comwrote:
Quote:
>>>[...]
>> But the "unrestricted access" issue is easily dealt with, in
>>the sense that the contents can be made "opaque." The tradition-
>>honored technique in C is for your "bobble.h" to omit any mention
>>of the elements of a struct bobble_s. You can declare a function
>>as accepting a struct bobble_s* as an argument or returning one
>>as a result without revealing what a struct bobble_s looks like,
>>or even revealing its size. See "incomplete type."
>>
>As it happens, I am quite familiar with the concept and the
>technique, but I didn't mention it explicitly because I took it
>for granted that bobble.h would provide an incomplete type. [...]
>
Your original message said
>
Quote:
we have definitions like

struct bobble_s {...};

in our bobble.h.
>
>... and the presence of `{...}' led me to believe you were
>contemplating a complete struct declaration, elements and all.
>What *did* you mean by `{...}'?
You're right, that's what I wrote. My bad. Take it as my having
meant to write

we have definitions lik

struct bobble_s {...};

in our bobble.c and struct bobble_s; in bobble.h.

If I recall correctly, I had intended to mention incomplete types
later on in the article and simply forgot. My apologies for
sending you down a false trail.



Richard Harter, cri@tiac.net
http://home.tiac.net/~cri, http://www.varinoma.com
Save the Earth now!!
It's the only planet with chocolate.
Closed Thread