home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / gnu / gcc-2.5.8-bin.lha / info / gcc.info-10 (.txt) < prev    next >
GNU Info File  |  1994-02-21  |  38KB  |  648 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.55 from the input
  2. file gcc.texi.
  3.    This file documents the use and the internals of the GNU compiler.
  4.    Published by the Free Software Foundation 675 Massachusetts Avenue
  5. Cambridge, MA 02139 USA
  6.    Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
  7.    Permission is granted to make and distribute verbatim copies of this
  8. manual provided the copyright notice and this permission notice are
  9. preserved on all copies.
  10.    Permission is granted to copy and distribute modified versions of
  11. this manual under the conditions for verbatim copying, provided also
  12. that the sections entitled "GNU General Public License" and "Protect
  13. Your Freedom--Fight `Look And Feel'" are included exactly as in the
  14. original, and provided that the entire resulting derived work is
  15. distributed under the terms of a permission notice identical to this
  16.    Permission is granted to copy and distribute translations of this
  17. manual into another language, under the above conditions for modified
  18. versions, except that the sections entitled "GNU General Public
  19. License" and "Protect Your Freedom--Fight `Look And Feel'", and this
  20. permission notice, may be included in translations approved by the Free
  21. Software Foundation instead of in the original English.
  22. File: gcc.info,  Node: Bug Reporting,  Next: Sending Patches,  Prev: Bug Lists,  Up: Bugs
  23. How to Report Bugs
  24. ==================
  25.    The fundamental principle of reporting bugs usefully is this:
  26. *report all the facts*.  If you are not sure whether to state a fact or
  27. leave it out, state it!
  28.    Often people omit facts because they think they know what causes the
  29. problem and they conclude that some details don't matter.  Thus, you
  30. might assume that the name of the variable you use in an example does
  31. not matter.  Well, probably it doesn't, but one cannot be sure.
  32. Perhaps the bug is a stray memory reference which happens to fetch from
  33. the location where that name is stored in memory; perhaps, if the name
  34. were different, the contents of that location would fool the compiler
  35. into doing the right thing despite the bug.  Play it safe and give a
  36. specific, complete example.  That is the easiest thing for you to do,
  37. and the most helpful.
  38.    Keep in mind that the purpose of a bug report is to enable someone to
  39. fix the bug if it is not known.  It isn't very important what happens if
  40. the bug is already known.  Therefore, always write your bug reports on
  41. the assumption that the bug is not known.
  42.    Sometimes people give a few sketchy facts and ask, "Does this ring a
  43. bell?"  This cannot help us fix a bug, so it is basically useless.  We
  44. respond by asking for enough details to enable us to investigate.  You
  45. might as well expedite matters by sending them to begin with.
  46.    Try to make your bug report self-contained.  If we have to ask you
  47. for more information, it is best if you include all the previous
  48. information in your response, as well as the information that was
  49. missing.
  50.    To enable someone to investigate the bug, you should include all
  51. these things:
  52.    * The version of GNU CC.  You can get this by running it with the
  53.      `-v' option.
  54.      Without this, we won't know whether there is any point in looking
  55.      for the bug in the current version of GNU CC.
  56.    * A complete input file that will reproduce the bug.  If the bug is
  57.      in the C preprocessor, send a source file and any header files
  58.      that it requires.  If the bug is in the compiler proper (`cc1'),
  59.      run your source file through the C preprocessor by doing `gcc -E
  60.      SOURCEFILE > OUTFILE', then include the contents of OUTFILE in the
  61.      bug report.  (When you do this, use the same `-I', `-D' or `-U'
  62.      options that you used in actual compilation.)
  63.      A single statement is not enough of an example.  In order to
  64.      compile it, it must be embedded in a complete file of compiler
  65.      input; and the bug might depend on the details of how this is done.
  66.      Without a real example one can compile, all anyone can do about
  67.      your bug report is wish you luck.  It would be futile to try to
  68.      guess how to provoke the bug.  For example, bugs in register
  69.      allocation and reloading frequently depend on every little detail
  70.      of the function they happen in.
  71.      Even if the input file that fails comes from a GNU program, you
  72.      should still send the complete test case.  Don't ask the GNU CC
  73.      maintainers to do the extra work of obtaining the program in
  74.      question--they are all overworked as it is.  Also, the problem may
  75.      depend on what is in the header files on your system; it is
  76.      unreliable for the GNU CC maintainers to try the problem with the
  77.      header files available to them.  By sending CPP output, you can
  78.      eliminate this source of uncertainty and save us a certain
  79.      percentage of wild goose chases.
  80.    * The command arguments you gave GNU CC or GNU C++ to compile that
  81.      example and observe the bug.  For example, did you use `-O'?  To
  82.      guarantee you won't omit something important, list all the options.
  83.      If we were to try to guess the arguments, we would probably guess
  84.      wrong and then we would not encounter the bug.
  85.    * The type of machine you are using, and the operating system name
  86.      and version number.
  87.    * The operands you gave to the `configure' command when you installed
  88.      the compiler.
  89.    * A complete list of any modifications you have made to the compiler
  90.      source.  (We don't promise to investigate the bug unless it
  91.      happens in an unmodified compiler.  But if you've made
  92.      modifications and don't tell us, then you are sending us on a wild
  93.      goose chase.)
  94.      Be precise about these changes.  A description in English is not
  95.      enough--send a context diff for them.
  96.      Adding files of your own (such as a machine description for a
  97.      machine we don't support) is a modification of the compiler source.
  98.    * Details of any other deviations from the standard procedure for
  99.      installing GNU CC.
  100.    * A description of what behavior you observe that you believe is
  101.      incorrect.  For example, "The compiler gets a fatal signal," or,
  102.      "The assembler instruction at line 208 in the output is incorrect."
  103.      Of course, if the bug is that the compiler gets a fatal signal,
  104.      then one can't miss it.  But if the bug is incorrect output, the
  105.      maintainer might not notice unless it is glaringly wrong.  None of
  106.      us has time to study all the assembler code from a 50-line C
  107.      program just on the chance that one instruction might be wrong.
  108.      We need *you* to do this part!
  109.      Even if the problem you experience is a fatal signal, you should
  110.      still say so explicitly.  Suppose something strange is going on,
  111.      such as, your copy of the compiler is out of synch, or you have
  112.      encountered a bug in the C library on your system.  (This has
  113.      happened!)  Your copy might crash and the copy here would not.  If
  114.      you said to expect a crash, then when the compiler here fails to
  115.      crash, we would know that the bug was not happening.  If you don't
  116.      say to expect a crash, then we would not know whether the bug was
  117.      happening.  We would not be able to draw any conclusion from our
  118.      observations.
  119.      If the problem is a diagnostic when compiling GNU CC with some
  120.      other compiler, say whether it is a warning or an error.
  121.      Often the observed symptom is incorrect output when your program
  122.      is run.  Sad to say, this is not enough information unless the
  123.      program is short and simple.  None of us has time to study a large
  124.      program to figure out how it would work if compiled correctly,
  125.      much less which line of it was compiled wrong.  So you will have
  126.      to do that.  Tell us which source line it is, and what incorrect
  127.      result happens when that line is executed.  A person who
  128.      understands the program can find this as easily as finding a bug
  129.      in the program itself.
  130.    * If you send examples of assembler code output from GNU CC or GNU
  131.      C++, please use `-g' when you make them.  The debugging information
  132.      includes source line numbers which are essential for correlating
  133.      the output with the input.
  134.    * If you wish to mention something in the GNU CC source, refer to it
  135.      by context, not by line number.
  136.      The line numbers in the development sources don't match those in
  137.      your sources.  Your line numbers would convey no useful
  138.      information to the maintainers.
  139.    * Additional information from a debugger might enable someone to
  140.      find a problem on a machine which he does not have available.
  141.      However, you need to think when you collect this information if
  142.      you want it to have any chance of being useful.
  143.      For example, many people send just a backtrace, but that is never
  144.      useful by itself.  A simple backtrace with arguments conveys little
  145.      about GNU CC because the compiler is largely data-driven; the same
  146.      functions are called over and over for different RTL insns, doing
  147.      different things depending on the details of the insn.
  148.      Most of the arguments listed in the backtrace are useless because
  149.      they are pointers to RTL list structure.  The numeric values of the
  150.      pointers, which the debugger prints in the backtrace, have no
  151.      significance whatever; all that matters is the contents of the
  152.      objects they point to (and most of the contents are other such
  153.      pointers).
  154.      In addition, most compiler passes consist of one or more loops that
  155.      scan the RTL insn sequence.  The most vital piece of information
  156.      about such a loop--which insn it has reached--is usually in a
  157.      local variable, not in an argument.
  158.      What you need to provide in addition to a backtrace are the values
  159.      of the local variables for several stack frames up.  When a local
  160.      variable or an argument is an RTX, first print its value and then
  161.      use the GDB command `pr' to print the RTL expression that it points
  162.      to.  (If GDB doesn't run on your machine, use your debugger to call
  163.      the function `debug_rtx' with the RTX as an argument.)  In
  164.      general, whenever a variable is a pointer, its value is no use
  165.      without the data it points to.
  166.    Here are some things that are not necessary:
  167.    * A description of the envelope of the bug.
  168.      Often people who encounter a bug spend a lot of time investigating
  169.      which changes to the input file will make the bug go away and which
  170.      changes will not affect it.
  171.      This is often time consuming and not very useful, because the way
  172.      we will find the bug is by running a single example under the
  173.      debugger with breakpoints, not by pure deduction from a series of
  174.      examples.  You might as well save your time for something else.
  175.      Of course, if you can find a simpler example to report *instead* of
  176.      the original one, that is a convenience.  Errors in the output
  177.      will be easier to spot, running under the debugger will take less
  178.      time, etc.  Most GNU CC bugs involve just one function, so the
  179.      most straightforward way to simplify an example is to delete all
  180.      the function definitions except the one where the bug occurs.
  181.      Those earlier in the file may be replaced by external declarations
  182.      if the crucial function depends on them.  (Exception: inline
  183.      functions may affect compilation of functions defined later in the
  184.      file.)
  185.      However, simplification is not vital; if you don't want to do this,
  186.      report the bug anyway and send the entire test case you used.
  187.    * In particular, some people insert conditionals `#ifdef BUG' around
  188.      a statement which, if removed, makes the bug not happen.  These
  189.      are just clutter; we won't pay any attention to them anyway.
  190.      Besides, you should send us cpp output, and that can't have
  191.      conditionals.
  192.    * A patch for the bug.
  193.      A patch for the bug is useful if it is a good one.  But don't omit
  194.      the necessary information, such as the test case, on the
  195.      assumption that a patch is all we need.  We might see problems
  196.      with your patch and decide to fix the problem another way, or we
  197.      might not understand it at all.
  198.      Sometimes with a program as complicated as GNU CC it is very hard
  199.      to construct an example that will make the program follow a
  200.      certain path through the code.  If you don't send the example, we
  201.      won't be able to construct one, so we won't be able to verify that
  202.      the bug is fixed.
  203.      And if we can't understand what bug you are trying to fix, or why
  204.      your patch should be an improvement, we won't install it.  A test
  205.      case will help us to understand.
  206.      *Note Sending Patches::, for guidelines on how to make it easy for
  207.      us to understand and install your patches.
  208.    * A guess about what the bug is or what it depends on.
  209.      Such guesses are usually wrong.  Even I can't guess right about
  210.      such things without first using the debugger to find the facts.
  211.    * A core dump file.
  212.      We have no way of examining a core dump for your type of machine
  213.      unless we have an identical system--and if we do have one, we
  214.      should be able to reproduce the crash ourselves.
  215. File: gcc.info,  Node: Sending Patches,  Prev: Bug Reporting,  Up: Bugs
  216. Sending Patches for GNU CC
  217. ==========================
  218.    If you would like to write bug fixes or improvements for the GNU C
  219. compiler, that is very helpful.  When you send your changes, please
  220. follow these guidelines to avoid causing extra work for us in studying
  221. the patches.
  222.    If you don't follow these guidelines, your information might still be
  223. useful, but using it will take extra work.  Maintaining GNU C is a lot
  224. of work in the best of circumstances, and we can't keep up unless you do
  225. your best to help.
  226.    * Send an explanation with your changes of what problem they fix or
  227.      what improvement they bring about.  For a bug fix, just include a
  228.      copy of the bug report, and explain why the change fixes the bug.
  229.      (Referring to a bug report is not as good as including it, because
  230.      then we will have to look it up, and we have probably already
  231.      deleted it if we've already fixed the bug.)
  232.    * Always include a proper bug report for the problem you think you
  233.      have fixed.  We need to convince ourselves that the change is
  234.      right before installing it.  Even if it is right, we might have
  235.      trouble judging it if we don't have a way to reproduce the problem.
  236.    * Include all the comments that are appropriate to help people
  237.      reading the source in the future understand why this change was
  238.      needed.
  239.    * Don't mix together changes made for different reasons.  Send them
  240.      *individually*.
  241.      If you make two changes for separate reasons, then we might not
  242.      want to install them both.  We might want to install just one.  If
  243.      you send them all jumbled together in a single set of diffs, we
  244.      have to do extra work to disentangle them--to figure out which
  245.      parts of the change serve which purpose.  If we don't have time
  246.      for this, we might have to ignore your changes entirely.
  247.      If you send each change as soon as you have written it, with its
  248.      own explanation, then the two changes never get tangled up, and we
  249.      can consider each one properly without any extra work to
  250.      disentangle them.
  251.      Ideally, each change you send should be impossible to subdivide
  252.      into parts that we might want to consider separately, because each
  253.      of its parts gets its motivation from the other parts.
  254.    * Send each change as soon as that change is finished.  Sometimes
  255.      people think they are helping us by accumulating many changes to
  256.      send them all together.  As explained above, this is absolutely
  257.      the worst thing you could do.
  258.      Since you should send each change separately, you might as well
  259.      send it right away.  That gives us the option of installing it
  260.      immediately if it is important.
  261.    * Use `diff -c' to make your diffs.  Diffs without context are hard
  262.      for us to install reliably.  More than that, they make it hard for
  263.      us to study the diffs to decide whether we want to install them.
  264.      Unidiff format is better than contextless diffs, but not as easy
  265.      to read as `-c' format.
  266.      If you have GNU diff, use `diff -cp', which shows the name of the
  267.      function that each change occurs in.
  268.    * Write the change log entries for your changes.  We get lots of
  269.      changes, and we don't have time to do all the change log writing
  270.      ourselves.
  271.      Read the `ChangeLog' file to see what sorts of information to put
  272.      in, and to learn the style that we use.  The purpose of the change
  273.      log is to show people where to find what was changed.  So you need
  274.      to be specific about what functions you changed; in large
  275.      functions, it's often helpful to indicate where within the
  276.      function the change was.
  277.      On the other hand, once you have shown people where to find the
  278.      change, you need not explain its purpose.  Thus, if you add a new
  279.      function, all you need to say about it is that it is new.  If you
  280.      feel that the purpose needs explaining, it probably does--but the
  281.      explanation will be much more useful if you put it in comments in
  282.      the code.
  283.      If you would like your name to appear in the header line for who
  284.      made the change, send us the header line.
  285.    * When you write the fix, keep in mind that we can't install a
  286.      change that would break other systems.
  287.      People often suggest fixing a problem by changing
  288.      machine-independent files such as `toplev.c' to do something
  289.      special that a particular system needs.  Sometimes it is totally
  290.      obvious that such changes would break GNU CC for almost all users.
  291.      We can't possibly make a change like that.  At best it might tell
  292.      us how to write another patch that would solve the problem
  293.      acceptably.
  294.      Sometimes people send fixes that *might* be an improvement in
  295.      general--but it is hard to be sure of this.  It's hard to install
  296.      such changes because we have to study them very carefully.  Of
  297.      course, a good explanation of the reasoning by which you concluded
  298.      the change was correct can help convince us.
  299.      The safest changes are changes to the configuration files for a
  300.      particular machine.  These are safe because they can't create new
  301.      bugs on other machines.
  302.      Please help us keep up with the workload by designing the patch in
  303.      a form that is good to install.
  304. File: gcc.info,  Node: Service,  Next: VMS,  Prev: Bugs,  Up: Top
  305. How To Get Help with GNU CC
  306. ***************************
  307.    If you need help installing, using or changing GNU CC, there are two
  308. ways to find it:
  309.    * Send a message to a suitable network mailing list.  First try
  310.      `bug-gcc@prep.ai.mit.edu', and if that brings no response, try
  311.      `help-gcc@prep.ai.mit.edu'.
  312.    * Look in the service directory for someone who might help you for a
  313.      fee.  The service directory is found in the file named `SERVICE'
  314.      in the GNU CC distribution.
  315. File: gcc.info,  Node: VMS,  Next: Portability,  Prev: Service,  Up: Top
  316. Using GNU CC on VMS
  317. *******************
  318. * Menu:
  319. * Include Files and VMS::  Where the preprocessor looks for the include files.
  320. * Global Declarations::    How to do globaldef, globalref and globalvalue with
  321.                            GNU CC.
  322. * VMS Misc::           Misc information.
  323. File: gcc.info,  Node: Include Files and VMS,  Next: Global Declarations,  Up: VMS
  324. Include Files and VMS
  325. =====================
  326.    Due to the differences between the filesystems of Unix and VMS, GNU
  327. CC attempts to translate file names in `#include' into names that VMS
  328. will understand.  The basic strategy is to prepend a prefix to the
  329. specification of the include file, convert the whole filename to a VMS
  330. filename, and then try to open the file.  GNU CC tries various prefixes
  331. one by one until one of them succeeds:
  332.   1. The first prefix is the `GNU_CC_INCLUDE:' logical name: this is
  333.      where GNU C header files are traditionally stored.  If you wish to
  334.      store header files in non-standard locations, then you can assign
  335.      the logical `GNU_CC_INCLUDE' to be a search list, where each
  336.      element of the list is suitable for use with a rooted logical.
  337.   2. The next prefix tried is `SYS$SYSROOT:[SYSLIB.]'.  This is where
  338.      VAX-C header files are traditionally stored.
  339.   3. If the include file specification by itself is a valid VMS
  340.      filename, the preprocessor then uses this name with no prefix in
  341.      an attempt to open the include file.
  342.   4. If the file specification is not a valid VMS filename (i.e. does
  343.      not contain a device or a directory specifier, and contains a `/'
  344.      character), the preprocessor tries to convert it from Unix syntax
  345.      to VMS syntax.
  346.      Conversion works like this: the first directory name becomes a
  347.      device, and the rest of the directories are converted into
  348.      VMS-format directory names.  For example, the name `X11/foobar.h'
  349.      is translated to `X11:[000000]foobar.h' or `X11:foobar.h',
  350.      whichever one can be opened.  This strategy allows you to assign a
  351.      logical name to point to the actual location of the header files.
  352.   5. If none of these strategies succeeds, the `#include' fails.
  353.    Include directives of the form:
  354.      #include foobar
  355. are a common source of incompatibility between VAX-C and GNU CC.  VAX-C
  356. treats this much like a standard `#include <foobar.h>' directive.  That
  357. is incompatible with the ANSI C behavior implemented by GNU CC: to
  358. expand the name `foobar' as a macro.  Macro expansion should eventually
  359. yield one of the two standard formats for `#include':
  360.      #include "FILE"
  361.      #include <FILE>
  362.    If you have this problem, the best solution is to modify the source
  363. to convert the `#include' directives to one of the two standard forms.
  364. That will work with either compiler.  If you want a quick and dirty fix,
  365. define the file names as macros with the proper expansion, like this:
  366.      #define stdio <stdio.h>
  367. This will work, as long as the name doesn't conflict with anything else
  368. in the program.
  369.    Another source of incompatibility is that VAX-C assumes that:
  370.      #include "foobar"
  371. is actually asking for the file `foobar.h'.  GNU CC does not make this
  372. assumption, and instead takes what you ask for literally; it tries to
  373. read the file `foobar'.  The best way to avoid this problem is to
  374. always specify the desired file extension in your include directives.
  375.    GNU CC for VMS is distributed with a set of include files that is
  376. sufficient to compile most general purpose programs.  Even though the
  377. GNU CC distribution does not contain header files to define constants
  378. and structures for some VMS system-specific functions, there is no
  379. reason why you cannot use GNU CC with any of these functions.  You first
  380. may have to generate or create header files, either by using the public
  381. domain utility `UNSDL' (which can be found on a DECUS tape), or by
  382. extracting the relevant modules from one of the system macro libraries,
  383. and using an editor to construct a C header file.
  384.    A `#include' file name cannot contain a DECNET node name.  The
  385. preprocessor reports an I/O error if you attempt to use a node name,
  386. whether explicitly, or implicitly via a logical name.
  387. File: gcc.info,  Node: Global Declarations,  Next: VMS Misc,  Prev: Include Files and VMS,  Up: VMS
  388. Global Declarations and VMS
  389. ===========================
  390.    GNU CC does not provide the `globalref', `globaldef' and
  391. `globalvalue' keywords of VAX-C.  You can get the same effect with an
  392. obscure feature of GAS, the GNU assembler.  (This requires GAS version
  393. 1.39 or later.)  The following macros allow you to use this feature in
  394. a fairly natural way:
  395.      #ifdef __GNUC__
  396.      #define GLOBALREF(TYPE,NAME)                      \
  397.        TYPE NAME                                       \
  398.        asm ("_$$PsectAttributes_GLOBALSYMBOL$$" #NAME)
  399.      #define GLOBALDEF(TYPE,NAME,VALUE)                \
  400.        TYPE NAME                                       \
  401.        asm ("_$$PsectAttributes_GLOBALSYMBOL$$" #NAME) \
  402.          = VALUE
  403.      #define GLOBALVALUEREF(TYPE,NAME)                 \
  404.        const TYPE NAME[1]                              \
  405.        asm ("_$$PsectAttributes_GLOBALVALUE$$" #NAME)
  406.      #define GLOBALVALUEDEF(TYPE,NAME,VALUE)           \
  407.        const TYPE NAME[1]                              \
  408.        asm ("_$$PsectAttributes_GLOBALVALUE$$" #NAME)  \
  409.          = {VALUE}
  410.      #else
  411.      #define GLOBALREF(TYPE,NAME) \
  412.        globalref TYPE NAME
  413.      #define GLOBALDEF(TYPE,NAME,VALUE) \
  414.        globaldef TYPE NAME = VALUE
  415.      #define GLOBALVALUEDEF(TYPE,NAME,VALUE) \
  416.        globalvalue TYPE NAME = VALUE
  417.      #define GLOBALVALUEREF(TYPE,NAME) \
  418.        globalvalue TYPE NAME
  419.      #endif
  420. (The `_$$PsectAttributes_GLOBALSYMBOL' prefix at the start of the name
  421. is removed by the assembler, after it has modified the attributes of
  422. the symbol).  These macros are provided in the VMS binaries
  423. distribution in a header file `GNU_HACKS.H'.  An example of the usage
  424.      GLOBALREF (int, ijk);
  425.      GLOBALDEF (int, jkl, 0);
  426.    The macros `GLOBALREF' and `GLOBALDEF' cannot be used
  427. straightforwardly for arrays, since there is no way to insert the array
  428. dimension into the declaration at the right place.  However, you can
  429. declare an array with these macros if you first define a typedef for the
  430. array type, like this:
  431.      typedef int intvector[10];
  432.      GLOBALREF (intvector, foo);
  433.    Array and structure initializers will also break the macros; you can
  434. define the initializer to be a macro of its own, or you can expand the
  435. `GLOBALDEF' macro by hand.  You may find a case where you wish to use
  436. the `GLOBALDEF' macro with a large array, but you are not interested in
  437. explicitly initializing each element of the array.  In such cases you
  438. can use an initializer like: `{0,}', which will initialize the entire
  439. array to `0'.
  440.    A shortcoming of this implementation is that a variable declared with
  441. `GLOBALVALUEREF' or `GLOBALVALUEDEF' is always an array.  For example,
  442. the declaration:
  443.      GLOBALVALUEREF(int, ijk);
  444. declares the variable `ijk' as an array of type `int [1]'.  This is
  445. done because a globalvalue is actually a constant; its "value" is what
  446. the linker would normally consider an address.  That is not how an
  447. integer value works in C, but it is how an array works.  So treating
  448. the symbol as an array name gives consistent results--with the
  449. exception that the value seems to have the wrong type.  *Don't try to
  450. access an element of the array.*  It doesn't have any elements.  The
  451. array "address" may not be the address of actual storage.
  452.    The fact that the symbol is an array may lead to warnings where the
  453. variable is used.  Insert type casts to avoid the warnings.  Here is an
  454. example; it takes advantage of the ANSI C feature allowing macros that
  455. expand to use the same name as the macro itself.
  456.      GLOBALVALUEREF (int, ss$_normal);
  457.      GLOBALVALUEDEF (int, xyzzy,123);
  458.      #ifdef __GNUC__
  459.      #define ss$_normal ((int) ss$_normal)
  460.      #define xyzzy ((int) xyzzy)
  461.      #endif
  462.    Don't use `globaldef' or `globalref' with a variable whose type is
  463. an enumeration type; this is not implemented.  Instead, make the
  464. variable an integer, and use a `globalvaluedef' for each of the
  465. enumeration values.  An example of this would be:
  466.      #ifdef __GNUC__
  467.      GLOBALDEF (int, color, 0);
  468.      GLOBALVALUEDEF (int, RED, 0);
  469.      GLOBALVALUEDEF (int, BLUE, 1);
  470.      GLOBALVALUEDEF (int, GREEN, 3);
  471.      #else
  472.      enum globaldef color {RED, BLUE, GREEN = 3};
  473.      #endif
  474. File: gcc.info,  Node: VMS Misc,  Prev: Global Declarations,  Up: VMS
  475. Other VMS Issues
  476. ================
  477.    GNU CC automatically arranges for `main' to return 1 by default if
  478. you fail to specify an explicit return value.  This will be interpreted
  479. by VMS as a status code indicating a normal successful completion.
  480. Version 1 of GNU CC did not provide this default.
  481.    GNU CC on VMS works only with the GNU assembler, GAS.  You need
  482. version 1.37 or later of GAS in order to produce value debugging
  483. information for the VMS debugger.  Use the ordinary VMS linker with the
  484. object files produced by GAS.
  485.    Under previous versions of GNU CC, the generated code would
  486. occasionally give strange results when linked to the sharable `VAXCRTL'
  487. library.  Now this should work.
  488.    A caveat for use of `const' global variables: the `const' modifier
  489. must be specified in every external declaration of the variable in all
  490. of the source files that use that variable.  Otherwise the linker will
  491. issue warnings about conflicting attributes for the variable.  Your
  492. program will still work despite the warnings, but the variable will be
  493. placed in writable storage.
  494.    Although the VMS linker does distinguish between upper and lower case
  495. letters in global symbols, most VMS compilers convert all such symbols
  496. into upper case and most run-time library routines also have upper case
  497. names.  To be able to reliably call such routines, GNU CC (by means of
  498. the assembler GAS) converts global symbols into upper case like other
  499. VMS compilers.  However, since the usual practice in C is to distinguish
  500. case, GNU CC (via GAS) tries to preserve usual C behavior by augmenting
  501. each name that is not all lower case.  This means truncating the name
  502. to at most 23 characters and then adding more characters at the end
  503. which encode the case pattern of those 23.   Names which contain at
  504. least one dollar sign are an exception; they are converted directly into
  505. upper case without augmentation.
  506.    Name augmentation yields bad results for programs that use
  507. precompiled libraries (such as Xlib) which were generated by another
  508. compiler.  You can use the compiler option `/NOCASE_HACK' to inhibit
  509. augmentation; it makes external C functions and variables
  510. case-independent as is usual on VMS.  Alternatively, you could write
  511. all references to the functions and variables in such libraries using
  512. lower case; this will work on VMS, but is not portable to other
  513. systems.  The compiler option `/NAMES' also provides control over
  514. global name handling.
  515.    Function and variable names are handled somewhat differently with GNU
  516. C++.  The GNU C++ compiler performs "name mangling" on function names,
  517. which means that it adds information to the function name to describe
  518. the data types of the arguments that the function takes.  One result of
  519. this is that the name of a function can become very long.  Since the
  520. VMS linker only recognizes the first 31 characters in a name, special
  521. action is taken to ensure that each function and variable has a unique
  522. name that can be represented in 31 characters.
  523.    If the name (plus a name augmentation, if required) is less than 32
  524. characters in length, then no special action is performed.  If the name
  525. is longer than 31 characters, the assembler (GAS) will generate a hash
  526. string based upon the function name, truncate the function name to 23
  527. characters, and append the hash string to the truncated name.  If the
  528. `/VERBOSE' compiler option is used, the assembler will print both the
  529. full and truncated names of each symbol that is truncated.
  530.    The `/NOCASE_HACK' compiler option should not be used when you are
  531. compiling programs that use libg++.  libg++ has several instances of
  532. objects (i.e.  `Filebuf' and `filebuf') which become indistinguishable
  533. in a case-insensitive environment.  This leads to cases where you need
  534. to inhibit augmentation selectively (if you were using libg++ and Xlib
  535. in the same program, for example).  There is no special feature for
  536. doing this, but you can get the result by defining a macro for each
  537. mixed case symbol for which you wish to inhibit augmentation.  The
  538. macro should expand into the lower case equivalent of itself.  For
  539. example:
  540.      #define StuDlyCapS studlycaps
  541.    These macro definitions can be placed in a header file to minimize
  542. the number of changes to your source code.
  543. File: gcc.info,  Node: Portability,  Next: Interface,  Prev: VMS,  Up: Top
  544. GNU CC and Portability
  545. **********************
  546.    The main goal of GNU CC was to make a good, fast compiler for
  547. machines in the class that the GNU system aims to run on: 32-bit
  548. machines that address 8-bit bytes and have several general registers.
  549. Elegance, theoretical power and simplicity are only secondary.
  550.    GNU CC gets most of the information about the target machine from a
  551. machine description which gives an algebraic formula for each of the
  552. machine's instructions.  This is a very clean way to describe the
  553. target.  But when the compiler needs information that is difficult to
  554. express in this fashion, I have not hesitated to define an ad-hoc
  555. parameter to the machine description.  The purpose of portability is to
  556. reduce the total work needed on the compiler; it was not of interest
  557. for its own sake.
  558.    GNU CC does not contain machine dependent code, but it does contain
  559. code that depends on machine parameters such as endianness (whether the
  560. most significant byte has the highest or lowest address of the bytes in
  561. a word) and the availability of autoincrement addressing.  In the
  562. RTL-generation pass, it is often necessary to have multiple strategies
  563. for generating code for a particular kind of syntax tree, strategies
  564. that are usable for different combinations of parameters.  Often I have
  565. not tried to address all possible cases, but only the common ones or
  566. only the ones that I have encountered.  As a result, a new target may
  567. require additional strategies.  You will know if this happens because
  568. the compiler will call `abort'.  Fortunately, the new strategies can be
  569. added in a machine-independent fashion, and will affect only the target
  570. machines that need them.
  571. File: gcc.info,  Node: Interface,  Next: Passes,  Prev: Portability,  Up: Top
  572. Interfacing to GNU CC Output
  573. ****************************
  574.    GNU CC is normally configured to use the same function calling
  575. convention normally in use on the target system.  This is done with the
  576. machine-description macros described (*note Target Macros::.).
  577.    However, returning of structure and union values is done differently
  578. on some target machines.  As a result, functions compiled with PCC
  579. returning such types cannot be called from code compiled with GNU CC,
  580. and vice versa.  This does not cause trouble often because few Unix
  581. library routines return structures or unions.
  582.    GNU CC code returns structures and unions that are 1, 2, 4 or 8 bytes
  583. long in the same registers used for `int' or `double' return values.
  584. (GNU CC typically allocates variables of such types in registers also.)
  585. Structures and unions of other sizes are returned by storing them into
  586. an address passed by the caller (usually in a register).  The
  587. machine-description macros `STRUCT_VALUE' and `STRUCT_INCOMING_VALUE'
  588. tell GNU CC where to pass this address.
  589.    By contrast, PCC on most target machines returns structures and
  590. unions of any size by copying the data into an area of static storage,
  591. and then returning the address of that storage as if it were a pointer
  592. value.  The caller must copy the data from that memory area to the
  593. place where the value is wanted.  This is slower than the method used
  594. by GNU CC, and fails to be reentrant.
  595.    On some target machines, such as RISC machines and the 80386, the
  596. standard system convention is to pass to the subroutine the address of
  597. where to return the value.  On these machines, GNU CC has been
  598. configured to be compatible with the standard compiler, when this method
  599. is used.  It may not be compatible for structures of 1, 2, 4 or 8 bytes.
  600.    GNU CC uses the system's standard convention for passing arguments.
  601. On some machines, the first few arguments are passed in registers; in
  602. others, all are passed on the stack.  It would be possible to use
  603. registers for argument passing on any machine, and this would probably
  604. result in a significant speedup.  But the result would be complete
  605. incompatibility with code that follows the standard convention.  So this
  606. change is practical only if you are switching to GNU CC as the sole C
  607. compiler for the system.  We may implement register argument passing on
  608. certain machines once we have a complete GNU system so that we can
  609. compile the libraries with GNU CC.
  610.    On some machines (particularly the Sparc), certain types of arguments
  611. are passed "by invisible reference".  This means that the value is
  612. stored in memory, and the address of the memory location is passed to
  613. the subroutine.
  614.    If you use `longjmp', beware of automatic variables.  ANSI C says
  615. that automatic variables that are not declared `volatile' have undefined
  616. values after a `longjmp'.  And this is all GNU CC promises to do,
  617. because it is very difficult to restore register variables correctly,
  618. and one of GNU CC's features is that it can put variables in registers
  619. without your asking it to.
  620.    If you want a variable to be unaltered by `longjmp', and you don't
  621. want to write `volatile' because old C compilers don't accept it, just
  622. take the address of the variable.  If a variable's address is ever
  623. taken, even if just to compute it and ignore it, then the variable
  624. cannot go in a register:
  625.      {
  626.        int careful;
  627.        &careful;
  628.        ...
  629.      }
  630.    Code compiled with GNU CC may call certain library routines.  Most of
  631. them handle arithmetic for which there are no instructions.  This
  632. includes multiply and divide on some machines, and floating point
  633. operations on any machine for which floating point support is disabled
  634. with `-msoft-float'.  Some standard parts of the C library, such as
  635. `bcopy' or `memcpy', are also called automatically.  The usual function
  636. call interface is used for calling the library routines.
  637.    These library routines should be defined in the library `libgcc.a',
  638. which GNU CC automatically searches whenever it links a program.  On
  639. machines that have multiply and divide instructions, if hardware
  640. floating point is in use, normally `libgcc.a' is not needed, but it is
  641. searched just in case.
  642.    Each arithmetic function is defined in `libgcc1.c' to use the
  643. corresponding C arithmetic operator.  As long as the file is compiled
  644. with another C compiler, which supports all the C arithmetic operators,
  645. this file will work portably.  However, `libgcc1.c' does not work if
  646. compiled with GNU CC, because each arithmetic function would compile
  647. into a call to itself!
  648.