home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / fweb153.zip / fweb-1.53 / web / proto.hweb < prev    next >
Text File  |  1995-09-23  |  3KB  |  127 lines

  1. @z --- proto.hweb ---
  2.  
  3. FWEB version 1.53 (September 23, 1995)
  4.  
  5. Based on version 0.5 of S. Levy's CWEB [copyright (C) 1987 Princeton University]
  6.  
  7. @x-----------------------------------------------------------------------------
  8.  
  9. @ In this header we handle stuff related to function prototypes.
  10.  
  11. @ The |PROTO| macro is used in \.{?\_type.hweb}.
  12.  
  13. @f PROTO $_EXPR
  14.  
  15. @<Operating system-specific...@>=
  16.  
  17. #if OLD_PROTOTYPES
  18.     #define PROTO(args) () // Old-style.
  19. #else
  20.     #define PROTO(args) args // New-style.
  21. #endif // |PROTOTYPES|
  22.  
  23. @ Here we deal with variable arguments.
  24.  
  25. @f ELLIPSIS $_EXPR
  26. @f VA_ARGS $_EXPR
  27. @f VA_LIST int
  28.  
  29. @<Operating system...@>=
  30.  
  31. #if(0)
  32. /* Sun's system is hopeless. */
  33. #if(NUM_VA_ARGS == 1)
  34.     #undef NUM_VA_ARGS
  35.     #define NUM_VA_ARGS 2
  36. #endif
  37. #endif
  38.  
  39. #if VARIABLE_ARGUMENTS
  40.     #define ELLIPSIS ,... /* ANSI standard; VAX allows for old-style
  41. declarations. */ 
  42.     #define VA_ARGS
  43.     #define VA_start
  44.     #if(NUM_VA_ARGS == 1)
  45.         #define VA_ALIST(args) (va_alist) // Sun's way.
  46.         #define VA_DCL(args) va_dcl
  47.         #define VA_START(a,n) va_start(a)
  48.     #else
  49.         #define VA_ALIST(args) args // ANSI way.
  50.         #define VA_DCL(args) args
  51.         #define VA_START(a,n) va_start(a,n)
  52.     #endif
  53.     #define VA_LIST(a) va_list a;
  54. #else
  55.     #define ELLIPSIS /* Not permitted by \.{gcc} for old-style
  56. declarations. */ 
  57.     #define VA_ARGS ,arg_ptr
  58.     #define arg_ptr arg1,arg2,arg3,arg4,arg5,arg6,\
  59. arg7,arg8,arg9,arg10,arg11,arg12,arg13
  60.     #define VA_start outer_char *arg1,*arg2,*arg3,*arg4,*arg5,*arg6,\
  61. *arg7,*arg8,*arg9,*arg10,*arg11,*arg12,*arg13;
  62.     #define VA_ALIST(args) args
  63.     #define VA_DCL(args) args
  64.     #define VA_LIST(a) 
  65.     #define VA_START(a,n)
  66.     #ifdef va_arg
  67.         #undef va_arg
  68.         #define va_arg(a,type) (type)"KLUDGE for va_arg"
  69.     #endif
  70.     #define va_end(a)
  71.     #define vprintf printf
  72.     #define vsprintf sprintf
  73. #endif /* ANSI variable arguments. */
  74.  
  75. @ The compilers have various understandings of |void| and |const|.
  76.  
  77. @f SRTN void /* Identifies functions that return |void|. */
  78. @f CONST static /* Identifies things that aren't changed by function calls,
  79.             or that can be placed in read-only memory. */
  80.  
  81. @<Operating system...@>=
  82.  
  83. #if !NO_VOID  /* \.{Machine-dependent}: For machines
  84. that understand about |void *| or |void fcn()|. */ 
  85.     #define VOID void
  86.     #define SRTN void
  87. #else
  88.     #define VOID /* For use in function declarations. */
  89.     #define void char
  90.     #define SRTN int
  91. #endif /* |void| stuff. */
  92.  
  93. #if KEEP_CONST
  94.     #define CONST const
  95. #else
  96.     #define CONST
  97. #endif
  98.  
  99. @ The following macros make either old- or new-style function declarations.
  100.  
  101. @f FCN $_EXPR
  102. @f C0 $_EXPR
  103. @f C1 $_EXPR
  104. @f C2 $_EXPR
  105. @f RPAR $_EXPR
  106.  
  107. @<Operating system...@>=
  108.  
  109. #if OLD_PROTOTYPES 
  110. /* Old-style declarations. */
  111.     #define FCN(args) args
  112.     #define C0(cmnt) ;
  113.     #define C1(cmnt) ;
  114.     #define C2(cmnt) ;VA_start
  115. #else
  116. /* New-style declarations.  To use these macros, function declarations
  117. should have form |main FCN((num_args,args))|.  See one of the \FWEB\
  118. sources for examples of the use of~|C0|, |C1|, and~|C2|. */
  119.     #define FCN(args) (
  120.  
  121.     #define C0(cmnt) , /* Intermediate comments. */
  122.  
  123.     #define C1(cmnt) ) /* Comment on last argument. */
  124.  
  125.     #define C2(cmnt) ,...) /* Variable args. */
  126. #endif // |PROTOTYPES|
  127.