home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 342b.lha / cpp / cpp.man < prev    next >
Text File  |  1990-01-26  |  11KB  |  397 lines

  1.  
  2.      CPP(1)                Amiga Programmer's Manual                 CPP(1)
  3.  
  4.  
  5.  
  6.      ›1mNAME
  7.       cpp ›0m- C Pre Processor. Macro-preprocess C programs.
  8.  
  9.      ›1mSYNOPSIS
  10.       ›0mcpp [-options] [infile [outfile]]
  11.  
  12.      ›1mDESCRIPTION
  13.       ›0mCPP reads a C source file, expands macros and include files,
  14.       and writes  an  input  file  for the C compiler.  If no file
  15.       arguments are given, CPP reads  from    stdin  and  writes  to
  16.       stdout.   If    one file argument is given, it will define the
  17.       input file, while two file arguments define both  input  and
  18.       output files.    The file name "-" is a synonym for stdin or
  19.       stdout as appropriate.
  20.  
  21.       The following options are supported.    Options may  be  given
  22.       in either case.
  23.  
  24.       -C   If  set, source-file comments are written to the output
  25.            file.  This allows the output of CPP to be used as  the
  26.            input to a program, such as lint, that expects commands
  27.            embedded in specially-formatted comments.
  28.  
  29.       -Dname=value
  30.            Define the name as if the programmer wrote
  31.  
  32.            #define name value
  33.  
  34.            at the  start  of  the  first file.  If "=value" is not
  35.            given, a value of "1" will be used.
  36.  
  37.            On non-unix and non-amiga systems, all alphabetic  text
  38.            will be forced to upper-case.
  39.  
  40.       -E   Always  return  "success" to the operating system, even
  41.            if errors were detected.  Note that some fatal  errors,
  42.            such  as  a  missing #include file, will terminate CPP,
  43.            returning "failure" even if the -E option is given.
  44.  
  45.       -Idirectory
  46.            Add this directory to the list of directories  searched
  47.            for #include "..."   and #include <...> commands.  Note
  48.            that there  is  no  space  between  the    "-I"  and  the
  49.            directory string.      More  than  one  -I  command  is
  50.            permitted.  On non-Unix systems "directory"  is  forced
  51.            to upper-case.
  52.  
  53.       -N   CPP  normally  predefines  some    symbols  defining  the
  54.            target computer    and  operating    system.    If  -N   is
  55.            specified, no  symbols will be predefined.  If -N -N is
  56.            specified,  the    "always  present"  symbols,  __LINE__,
  57.            __FILE__, __TIME__ and __DATE__ are not defined.
  58.  
  59.       -Stext
  60.            CPP  normally  assumes  that  the  size    of  the target
  61.            computer's basic variable types is the same as the size
  62.            of these types of the host  computer.    (This  can  be
  63.  
  64.  
  65.      1st PDC distribution          -1-
  66.  
  67.  
  68.      CPP(1)                Amiga Programmer's Manual                 CPP(1)
  69.  
  70.  
  71.            overridden  when  CPP  is  compiled,  however.)    The -S
  72.            option allows dynamic respecification of these  values.
  73.            "text"  is  a  string  of numbers, separated by commas,
  74.            that specifies  correct    sizes.      The  sizes  must  be
  75.            specified in the exact order:
  76.  
  77.            char short int long float double
  78.  
  79.            If  you    specify  the  option as "-S*text", pointers to
  80.            these types  will  be  specified.     -S*   takes   one
  81.            additional argument  for pointer to function (e.g.  int
  82.            (*)())
  83.  
  84.            For example, to specify sizes appropriate for a PDP-11,
  85.            you would write:
  86.  
  87.               c s i l f d func
  88.             -S1,2,2,2,4,8,
  89.            -S*2,2,2,2,2,2,2
  90.  
  91.            Note that all values must be specified.
  92.            ›3mNote also that this is not  allowed  by  the    11-Jan-88
  93.            Draft,  and  therefore  has  made  into    an option when
  94.            compiling Cpp.
  95.  
  96.       ›0m-Uname
  97.            Undefine the name as if
  98.  
  99.            #undef name
  100.  
  101.            were given.  On non-Unix systems, "name" will be forced
  102.            to upper-case.
  103.  
  104.       -Xnumber
  105.            Enable debugging code.  If no value is given,  a  value
  106.            of 1 will be used.  (For maintenence of CPP only.)
  107.  
  108.      ›1mPre›0m-›1mDefined Variables
  109.       ›0mWhen  CPP    begins    processing,  the following variables will
  110.       have been defined (unless the -N option is specified):
  111.  
  112.       Target computer (as appropriate):
  113.  
  114.           pdp11, vax, M68000 m68000 m68k, amiga m68000
  115.  
  116.       Target operating system (as appropriate):
  117.  
  118.           rsx, rt11, vms, unix, amigados
  119.  
  120.       Target compiler (as appropriate):
  121.  
  122.           decus, vax11c, pdc __PDC__
  123.  
  124.       The implementor may add  definitions    to  this  list.    The
  125.       default   definitions  match    the  definition  of  the  host
  126.       computer, operating system, and C compiler.
  127.  
  128.       The following are always available unless undefined  (or  -N
  129.  
  130.  
  131.      1st PDC distribution          -2-
  132.  
  133.  
  134.      CPP(1)                Amiga Programmer's Manual                 CPP(1)
  135.  
  136.  
  137.       was specified twice):
  138.  
  139.           __FILE__    The  input (or #include) file being compiled
  140.               (as a quoted string).
  141.           __LINE__    The line number being compiled.
  142.           __DATE__    The date of compilation as a    quoted    string
  143.               of the format "Mmm dd yyyy".
  144.           __TIME__    The  time  of  the start of compilation as a
  145.               quoted  string  of  the  format  "hh:mm:ss".
  146.               Thus,
  147.                   printf("Bug at line %s,", __LINE__);
  148.                   printf(" source file %s", __FILE__);
  149.                   printf(" compiled on %s %s",   __DATE__,
  150.               __TIME__);
  151.  
  152.      ›1mSupported directives
  153.           ›0m#assert <expression>
  154.           #define <token> <replacement>
  155.           #elif <expression>
  156.           #else <expression>
  157.           #endif
  158.           #error
  159.           #if <expression>
  160.           #ifdef <token>
  161.           #ifndef <token>
  162.           #include <filename>
  163.           #line <number> <filename>
  164.           #pragma <anything>
  165.           #undef <token>
  166.           #debug
  167.           #nodebug
  168.  
  169.       Unsupported # commands are copied verbatim into the  output,
  170.       so that maybe the compiler knows what to do with them.
  171.  
  172.      ›1mDraft Proposed Ansi Standard Considerations
  173.       ›0mThe   current   version   of  the    Draft  Proposed  Standard
  174.       explicitly states that "readers are requested not to specify
  175.       or claim conformance to this draft."  Readers and  users  of
  176.       Decus  CPP  should not assume that Decus CPP conforms to the
  177.       standard, or that it will conform to the actual  C  Language
  178.       Standard.
  179.  
  180.       When    CPP  is  itself  compiled,  many features of the Draft
  181.       Proposed  Standard  that  are  incompatible  with   existing
  182.       preprocessors may  be  disabled.   See the comments in CPP's
  183.       source for details.
  184.  
  185.       The latest  version  of  the    Draft  Proposed  Standard  (as
  186.       reflected in Decus CPP) is dated November 12, 1984, and bits
  187.       from K&R V2 are put in by Ois.
  188.  
  189.       Comments are    removed  from  the input text.    The comment is
  190.       replaced by  a  single  space  character.    The  -C    option
  191.       preserves comments, writing them to the output file.
  192.  
  193.       The '$'  character  is considered to be a letter.  This is a
  194.       permitted extension.
  195.  
  196.  
  197.      1st PDC distribution          -3-
  198.  
  199.  
  200.      CPP(1)                Amiga Programmer's Manual                 CPP(1)
  201.  
  202.  
  203.  
  204.       The following new features of C are processed by CPP:
  205.  
  206.           #if, #elif
  207.           #elif expression          (#else #if)
  208.           '\xNNN'                 (Hexadecimal constant)
  209.           '\a'                    (Ascii BELL)
  210.           '\v'                    (Ascii Vertical Tab)
  211.           #if defined NAME          1 if defined, 0 if not
  212.           #if defined (NAME)      1 if defined, 0 if not
  213.           #if sizeof (basic type)
  214.           #error              Generates error message
  215.           unary +
  216.           123U, 123LU          Unsigned ints and longs.
  217.           12.3L              Long double numbers
  218.           token##token          Token concatenation in macros
  219.           #macro-formal          String generation in macros
  220.           #include token          Expands to filename
  221.  
  222.       The  Draft  Proposed    Standard  has  extended  C,  adding  a
  223.       constant string concatenation operator, where
  224.  
  225.           "foo" "bar"
  226.  
  227.       is  regarded    as  the single string "foobar". (This does not
  228.       affect CPP's processing but does permit a  limited  form  of
  229.       macro   argument   substitution  into  strings  as  will  be
  230.       discussed.)
  231.  
  232.       The Standard Committee plans to add token  concatenation  to
  233.       #define command  lines.   One suggested implementation is as
  234.       follows: the sequence "Token1 ## Token2" is  treated  as  if
  235.       the programmer wrote "Token1Token2".
  236.  
  237.       This could be used as follows:
  238.  
  239.           #line 123
  240.           #define ATLINE foo ## __LINE__
  241.  
  242.       ATLINE would be defined as foo123.
  243.  
  244.       Note    that  "Token1" and "Token2" both must be valid tokens,
  245.       but the concatenation of their expanded forms may not  be  a
  246.       _single_ valid  token.    In    that  case, K&R state that the
  247.       behaviour is undefined.  So if you wish to make portable use
  248.       of this facility, do not do the following:
  249.  
  250.           #define cat(x, y) x ## y
  251.           cat(foo, 1.23)
  252.  
  253.       which will produce
  254.  
  255.           foo1.23
  256.  
  257.       and that is not a single token.
  258.  
  259.       If the tokens T1 and    T2  are  concatenated  into  T3,  this
  260.       implementation operates as follows:
  261.  
  262.  
  263.      1st PDC distribution          -4-
  264.  
  265.  
  266.      CPP(1)                Amiga Programmer's Manual                 CPP(1)
  267.  
  268.  
  269.  
  270.         1. Expand T1 if it is a macro.
  271.         2. Expand T2 if it is a macro.
  272.         3. Join the tokens, forming T3.
  273.         4. Rescan  T3,  looking  for  tokens, that may be expanded
  274.       again.
  275.  
  276.         A macro formal parameter will be  substituted  into  a
  277.       string  or character constant if it is the only component of
  278.       that constant:
  279.  
  280.           #define VECSIZE 123
  281.           #define vprint(name, size) \
  282.         printf("name" "[" "size" "] = {\n")
  283.         ... vprint(vector, VECSIZE);
  284.  
  285.       expands (effectively) to
  286.  
  287.         vprint("vector[123] = {\n");
  288.  
  289.       Note that this will be useful if your  C  compiler  supports
  290.       the new  string  concatenation  operation  noted  above.  As
  291.       implemented here, if you write
  292.  
  293.           #define string(arg) "arg"
  294.         ... string("foo") ...
  295.  
  296.       This    implementation    generates  "foo",  rather   than   the
  297.       strictly  correct  ""foo""  (which will probably generate an
  298.       error message).  This is, strictly speaking, an error in CPP
  299.       and may be removed from future  releases.    ›3mNote    that  the
  300.       above  feature  of  replacing macro formals inside quotes is
  301.       non-standard.  The Committee thought    the  following    to  be
  302.       better:
  303.  
  304.       ›0mIf  a macro formal argument is immediately preceeded by a #,
  305.       the argument supplied  when  expanding  the  macro  will  be
  306.       surrounded  by  double  quotes,  and    each  double  quote or
  307.       backslash will be preceeded by a backslash.  An  example  of
  308.       this would be:
  309.  
  310.           #define string(arg) #arg
  311.         ... string(foo) ...
  312.  
  313.       which  produces  "foo". Note that this feature is useless if
  314.       you want your string to contain an odd number of quotes:
  315.  
  316.           string(Hello");
  317.  
  318.       will     produce   an    error    message,   complaining     about
  319.       unterminated strings.
  320.  
  321.  
  322.      ›1mError messages
  323.       ›0mMany. CPP prints warning or error messages if you try to use
  324.       multiple-byte character constants (non-transportable) if you
  325.       #undef a symbol that was not defined, or if your program has
  326.       potentially nested comments.
  327.  
  328.  
  329.      1st PDC distribution          -5-
  330.  
  331.  
  332.      CPP(1)                Amiga Programmer's Manual                 CPP(1)
  333.  
  334.  
  335.      ›1mAuthor
  336.       ›0mMartin Minow, minor changes by RMS, FNF, OIS.
  337.  
  338.      ›1mBugs
  339.       ›0mThe  #if  expression  processor  uses  signed integers only.
  340.       I.e, #if 0xFFFFu < 0 may be TRUE.
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.      1st PDC distribution          -6-
  396.  
  397.