generic.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:2k
源码类别:

VxWorks

开发平台:

C/C++

  1. /*ident "@(#)cop4:stdlib/incl/generic.h 1.1" */
  2. /*******************************************************************************
  3.  
  4. C++ source for the C++ Language System, Release 3.0.  This product
  5. is a new release of the original cfront developed in the computer
  6. science research center of AT&T Bell Laboratories.
  7. Copyright (c) 1991 AT&T and UNIX System Laboratories, Inc.
  8. Copyright (c) 1984, 1989, 1990 AT&T.  All Rights Reserved.
  9. THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE of AT&T and UNIX System
  10. Laboratories, Inc.  The copyright notice above does not evidence
  11. any actual or intended publication of such source code.
  12. *******************************************************************************/
  13. #ifndef GENERICH
  14. #define GENERICH 1
  15. /* macros to paste tokens together to form new names */
  16. /* BSD and SystemV cpp's have different mechanisms for pasting tokens
  17.    together:  worse yet, suns run under BSD but have SYSV mechanism.
  18.    ANSI C has defined a new way.
  19. */
  20. #ifdef __STDC__
  21. /* ANSI C preprocessors will not expand the arguments to a macro;
  22.  * so we need to add a level of indirection to allow macro expansion of
  23.  * arguments.  (Reiser preprocessors allowed the first arg to be expanded;
  24.  * this method will allow both to be expanded, which is better than none.)
  25.  */
  26. #define name2(a,b)      _name2_aux(a,b)
  27. #define _name2_aux(a,b)      a##b
  28. #define name3(a,b,c)    _name3_aux(a,b,c)
  29. #define _name3_aux(a,b,c)    a##b##c
  30. #define name4(a,b,c,d)  _name4_aux(a,b,c,d)
  31. #define _name4_aux(a,b,c,d)  a##b##c##d
  32. #else 
  33. #ifdef sun
  34. /*System V way: although BSD is true*/
  35. #define name2(a,b) a/**/b
  36. #define name3(a,b,c) a/**/b/**/c
  37. #define name4(a,b,c,d) a/**/b/**/c/**/d
  38. #else
  39. #ifdef  BSD
  40. /*BSD way:*/
  41. #define name2(a,b) a
  42. b
  43. #define name3(a,b,c) a
  44. b
  45. c
  46. #define name4(a,b,c,d) a
  47. b
  48. c
  49. d
  50. #else
  51. /*System V way:*/
  52. #define name2(a,b) a/**/b
  53. #define name3(a,b,c) a/**/b/**/c
  54. #define name4(a,b,c,d) a/**/b/**/c/**/d
  55. #endif
  56. #endif
  57. #endif
  58. #define declare(a,t) name2(a,declare)(t)
  59. #define implement(a,t) name2(a,implement)(t)
  60. #define declare2(a,t1,t2) name2(a,declare2)(t1,t2)
  61. #define implement2(a,t1,t2) name2(a,implement2)(t1,t2)
  62. extern int genericerror(int,char*);
  63. typedef int (*GPT)(int,char*);
  64. #define set_handler(generic,type,x) name4(set_,type,generic,_handler)(x)
  65. #define errorhandler(generic,type) name3(type,generic,handler)
  66. #define callerror(generic,type,a,b) (*errorhandler(generic,type))(a,b)
  67. #endif