home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!rutgers!mcdhup!src4src!wozzle!alane
- From: alane@wozzle.linet.org (J. Alan Eldridge)
- Newsgroups: comp.lang.c
- Subject: Re: Qusetions about UC Berkerley header file. Help!
- Message-ID: <u7yNwB2w165w@wozzle.linet.org>
- Date: 31 Dec 92 20:38:29 GMT
- References: <1hlrgtINNs0e@function.mps.ohio-state.edu>
- Organization: Disorganization
- Lines: 50
-
- ren@function.mps.ohio-state.edu (Liming Ren) writes:
-
- > This question bugs me all the day. I hope it makes sense.
- >
- > I am reading two header files distributed by UC Berkley. One is search.h
- > and the other one is db.h (they are about hashing, Btree etc).
- >
- > (1) In search.h, there are several lines such as:
- >
- > int hcreate __P((unsigned int));
- > void hdestroy __P((void));
- > ENTRY *hsearch __P((ENTRY, ACTION));
- >
- > I don't understand this. It seems __P is a function returns ....(confused
- > here). What are hcreate , hdestroy etc anyway?
- >
- > (2) In db.h, there is a definition for DB:
- >
- > typedef struct __db {
- > DBTYPE type; /* underlying db type */
- > int (*close) __P((struct __db *));
- > int (*del) __P((const struct __db *, const DBT *, unsigned int))
- > int (*get) __P((const struct __db *, const DBT *, DBT *,
- > unsigned int));
- > int (*put) __P((const struct __db *, const DBT *, const DBT *,
- > unsigned int));
- > int (*seq) __P((const struct __db *, DBT *, DBT *, unsigned int)
- > int (*sync) __P((const struct __db *));
- > void *internal; /* access method private */
- > } DB;
- >
- > What is __P again? To my best knowledge, C does not support function
- > overloading. BUT what is this?
-
- Well, I guess it's something like:
-
- #if __STDC__
- #define __P(x) x
- #else
- #define __P(x) ()
- #endif
-
- This lets you prototype if your compiler supports it (ANSI), or use
- the old style if your compiler is old and senile (K&R).
-
-
-
-
- alane@wozzle.linet.org (J. Alan Eldridge)
- Fido: The University of Walamaloo 1:272/38.473
-