How is this useful ???

H

hotadvice

hi all

I was just browsing some code(actually apache)

and i found this :

typedef struct apr_pool_t apr_pool_t

How this is usefull??


Thanx in advance

Aman Aggarwal
 
R

Richard Bos

hotadvice said:
typedef struct apr_pool_t apr_pool_t

How this is usefull??

Erm... it defines a type alias for a struct type? How else would it be
useful? It means that instead of referring to that type as struct
apr_pool_t, you can now do so using just apr_pool_t. Saves a whole
whopping seven characters. Personally, I never bother unless I want to
hide the underlying type, but there are those who prefer this.

Richard
 
Z

Zara

hi all

I was just browsing some code(actually apache)

and i found this :

typedef struct apr_pool_t apr_pool_t

How this is usefull??


Thanx in advance

Aman Aggarwal

I'll be whipped for mentioning it, butusing this typedef you can write
the rest of the references to this struct in a way compatible both to
C and C++.

Please, do not beat me too much for naing Satan in tthis Temple... ;-)
 
M

Martin Ambuhl

hotadvice said:
I was just browsing some code(actually apache)
and i found this :
typedef struct apr_pool_t apr_pool_t
How this is usefull??

(Not at all without the missing semicolon.)
It saves typing the characters 'struct ' in declarations of 'struct
apr_pool_t' objects. If avoiding typing a few characters seems useful
to you, then the typedef begins to be useful if you use this type more
than 5 times (since typing the typedef itself must be offset).
 
D

Dave Thompson

I'll be whipped for mentioning it, butusing this typedef you can write
the rest of the references to this struct in a way compatible both to
C and C++.
Compatible with the usual and arguably preferred C++ style.

C++ does (also) allow you to use the C-like form, which it calls an
elaborated-type-specifier -- struct foo, class foo, union foo, or enum
foo -- as well as just foo. And in name conflict cases that are
arguably bad style anyway it requires it, as C always does.
- David.Thompson1 at worldnet.att.net
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top