home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 19111 < prev    next >
Encoding:
Internet Message Format  |  1992-12-31  |  2.1 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!rutgers!mcdhup!src4src!wozzle!alane
  2. From: alane@wozzle.linet.org (J. Alan Eldridge)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Qusetions about UC Berkerley header file. Help!
  5. Message-ID: <u7yNwB2w165w@wozzle.linet.org>
  6. Date: 31 Dec 92 20:38:29 GMT
  7. References: <1hlrgtINNs0e@function.mps.ohio-state.edu>
  8. Organization: Disorganization
  9. Lines: 50
  10.  
  11. ren@function.mps.ohio-state.edu (Liming Ren) writes:
  12.  
  13. > This question bugs me all the day. I hope it makes sense.
  14. > I am reading two header files distributed by UC Berkley. One is search.h
  15. > and the other one is db.h (they are about hashing, Btree etc).
  16. > (1) In search.h, there are several lines such as:
  17. > int      hcreate __P((unsigned int));
  18. > void     hdestroy __P((void));
  19. > ENTRY   *hsearch __P((ENTRY, ACTION));
  20. > I don't understand this. It seems __P is a function returns ....(confused 
  21. > here).  What are hcreate , hdestroy etc anyway?
  22. > (2) In db.h, there is a definition for  DB:
  23. > typedef struct __db {
  24. >         DBTYPE type;                    /* underlying db type */
  25. >         int (*close)    __P((struct __db *));
  26. >         int (*del)      __P((const struct __db *, const DBT *, unsigned int))
  27. >         int (*get)      __P((const struct __db *, const DBT *, DBT *,
  28. >                             unsigned int));
  29. >         int (*put)      __P((const struct __db *, const DBT *, const DBT *,
  30. >                             unsigned int));
  31. >         int (*seq)      __P((const struct __db *, DBT *, DBT *, unsigned int)
  32. >         int (*sync)     __P((const struct __db *));
  33. >         void *internal;                 /* access method private */
  34. > } DB;
  35. > What is __P again? To my best knowledge, C does not support function
  36. > overloading. BUT what is this? 
  37.  
  38. Well, I guess it's something like:
  39.  
  40. #if     __STDC__
  41. #define __P(x)  x
  42. #else
  43. #define __P(x)  ()
  44. #endif
  45.  
  46. This lets you prototype if your compiler supports it (ANSI), or use
  47. the old style if your compiler is old and senile (K&R).
  48.  
  49.  
  50.  
  51.  
  52. alane@wozzle.linet.org (J. Alan Eldridge)
  53. Fido: The University of Walamaloo 1:272/38.473
  54.