[LCP]typedefs in .h

Alton, Matthew Matthew.Alton at anheuser-busch.com
Sat Jan 19 10:20:47 UTC 2002


This is an interesting problem.  We would often like to
format data into printf()s for debugging output and
sundry other purposes.  Alas, other than the GNU typeof()
operator, I know of no decent method.  The problem
really gets nasty in pthreads-land where a pthread_t can
be absolutely anything from a short int to a void pointer
to a kernel struct.  Associate each pthread_t with it's
unique memory address, you say?  Fine, what's the real
type of an addr_t?  We're full circle.

I would be very interested in any suggestions for
overcoming this problem.

-----Original Message-----
From: Emil Tantilov [mailto:emocom at yahoo.com]
Sent: Friday, January 18, 2002 4:32 PM
To: linuxcprogramming at lists.linux.org.au
Subject: Re: [LCP]typedefs in .h



> But let me refine that answer Emil.
> 
> The method you were given will give you the "actual"
> type in THIS (ie:
> some specific) implementation. You can also examine
> the headers
> themslves (and remember, you can use an option
> specifying that these
> "hidden" things be expanded in the compile listing).
> They aren't
> "buried", only seems that way because the default is
> "don't expand and
> show me".
> 
> BUT --- there is no ACTUAL type for these things in
> C itself. That is
> the whole purpose of having them as abstract types
> defined via typedefs
> in headers. It makes your C source code independent
> of the way these
> must be defined for some specific implementation.
> Since any actual
> compile is for some specific implementation, as long
> as the the right
> header libraries* are used for that implementation,
> everything will work
> out WITHOUT any need to edit the source code.
> 
> Proper coding technique is for your code to make no
> assumptions about
> things that are not defined in C like "how long is
> an integer"
> 
> Mike

 I agree and understand the purpose of things being
made the way they are. However (I should've asked the
question in a different way perhaps ...) if I try to
display the result I *will* need to know the type,
otherwise the result won't be accurate (let's say if I
display number instead of text or char ...). In this
case fstat(), I can't display st_dev, not to mention I
have no idea what it represent and in what format ...

Emil

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/
_______________________________________________
This is the Linux C Programming List
:  http://lists.linux.org.au/listinfo/linuxcprogramming List



More information about the linuxCprogramming mailing list