tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: UVM typedef struct



On Tue, Jun 16, 2009 at 09:55:23AM -0500, Eric Haszlakiewicz wrote:
> 
> Or maybe Antti means:
> 
> struct mystruct;
> int foo(struct mystruct *);
> 
> That works with typedefs too, but you need to duplicate the typedef line:
> 
> struct mystruct;
> typedef struct mystruct mystruct_t;
> int foo(mystruct_t *);

The fact that the latter is a bug, means that you can only define
a typedef in one place  This is a problem if the functions that
use the type need to be in several header files - since you end up
either putting the typedef in a global file, of a file of its own.

In some places you'll see a 'struct foo' definition before a function
prototype where everywhere else the typedef is used!

From a language point of view there is little difference (other than
the number of characters needed) between using 'struct foo' and 'foo_t'
once 'typedef struct foo foo_t' is in scope.
(Except that, in C (but not C++), the struct namespace is separate
from all others.)

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index