By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,501 Members | 1,690 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,501 IT Pros & Developers. It's quick & easy.

How is this useful ???

P: n/a
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

Nov 15 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"hotadvice" <am******@gmail.com> wrote:
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
Nov 15 '05 #2

P: n/a
On 28 Oct 2005 04:57:16 -0700, "hotadvice" <am******@gmail.com> wrote:
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... ;-)
Nov 15 '05 #3

P: n/a
hotadvice wrote:
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).
Nov 15 '05 #4

P: n/a
On Fri, 28 Oct 2005 13:27:34 GMT, Zara <yo****@terra.es> wrote:
On 28 Oct 2005 04:57:16 -0700, "hotadvice" <am******@gmail.com> wrote:
typedef struct apr_pool_t apr_pool_t

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
Nov 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.