home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / gcc / cc1plus / !gcc / docs / c++ / !Readme next >
Encoding:
Text File  |  1996-11-10  |  8.6 KB  |  282 lines

  1. The GNU C++ compiler
  2. ====================
  3.  
  4. Introduction
  5. ------------
  6.  
  7. This is a port of the GNU C++ compiler (version 2.7.2) for the C++
  8. programming language to the Acorn range of ARM based machines, running
  9. under RISC OS. As such, this package is covered by the FSF General
  10. Public License (see the files docs.COPYING and docs.COPYINGLIB for details).
  11.  
  12. This port is © 1996 Nick Burrett
  13.  
  14. As with GNU programs, THERE IS NO WARRANTY OF ANY SORT
  15.  
  16. This compiler requires a minimum 3200Kb of free RAM for compilations.
  17.  
  18.  
  19. Files
  20. -----
  21.  
  22. This is a binary distribution only and consists of the following files:
  23.  
  24.   bin.cc1plus           The C++ compiler
  25.   bin.g++               The C++ compiler front end
  26.   docs.c++.!Readme    This C++ compiler introduction document
  27.  
  28. The compiler sources (about 27Mb) can be obtained from the sites listed at
  29. the end of docs.!Intro.
  30.  
  31. Installation
  32. ------------
  33.  
  34. Before attempting to use GNU C, it should be noted that this distribution
  35. will require the GCC front end files stored in the archive gccmain.zip.
  36. If you do not have a copy of this, it can be retrieved from
  37.   ftp://micros.hensa.ac.uk/micros/arch/riscos/b/b013/gccmain.zip
  38. and relevant mirrors.
  39.  
  40. GNU C++ 2.7.2 also requires UnixLib 3.7a or later, but not UnixLib 4.0.
  41. GNU C++ will not work with UnixLib 3.6e or earlier.
  42.  
  43.  
  44. Compiling C++ source
  45. --------------------
  46.  
  47. C++ source files can be kept in either the 'cc', 'c++' or 'cxx' directories.
  48. Headers files are stored in the 'h' directory.
  49.  
  50. C++ comes with an extra file called g++. g++ is a front end binary for the
  51. C++ compiler, and will automatically include the necessary run-time library
  52. needed by C++ whenever the compilation needs it.
  53.  
  54. Typing:
  55.     gcc -c cc.test
  56. or  g++ -c cc.test
  57.  
  58. will compile the C++ file, test, into an AOF file and store it in the 'o'
  59. directory.
  60.  
  61. Typing:
  62.   gcc cc.test -o test -lg++
  63.  
  64. is equivalent to:
  65.   g++ cc.test -o test
  66.  
  67. All GNU compilers require the library gcc:o.libgcc to operate. So separate
  68. compile and link operations must include this.
  69.  
  70.  
  71. Compiling and running the example programs
  72. ------------------------------------------
  73.  
  74. The following example programs are to be found in the directory !gcc.files.
  75. For each program, there is a list of the necessary command lines for how
  76. to compile, link and run the program.
  77.  
  78.  
  79. hellow
  80. ^^^^^^
  81. The standard C program.
  82.  
  83. Source:     cc.hellow
  84. Compile using:     gcc cc.hellow -o hellow
  85. Run using:     hellow
  86.  
  87.  
  88. Dhrystone 2.1
  89. ^^^^^^^^^^^^^
  90. This is a C++ derivative of the standard integer benchmark.
  91. You will probably need 4000K of WimpSlot on a non-RISC PC machine to
  92. compile this.
  93.  
  94. Source:        cc.dhrystone, h.Int, h.Char
  95.  
  96. Compile using:    gcc cc.dhrystone -o dhrystone -O2 -DQUICK
  97.  
  98. Run using:    dhrystone
  99.  
  100. When prompted for the number of iterations, use any number in the range
  101. 10000 to 200000.
  102.  
  103. There are several derivatives of this program that can be activated
  104. by adding certain command line options to gcc:
  105.  
  106.  
  107. To get standard integers and characters
  108. compile using:    gcc cc.dhrystone -o dhrystone -DBUILTIN
  109.  
  110. To use function calls instead of inlined function calls
  111. compile using:    gcc cc.dhrystone -o dhrystone -DCALLS
  112.  
  113. To make all class members virtual
  114. compile using:    gcc cc.dhrystone -o dhrystone -DVIRT
  115.  
  116. To use call-by-value, not by-reference
  117. compile using:    gcc cc.dhrystone -o dhrystone -DBYVAL
  118.  
  119. To eliminate mixed mode functions that avoid constructors
  120. compile using:    gcc cc.dhrystone -o dhrystone -DCONVERT
  121.  
  122. To eliminate the use of named return values
  123. compile using:    gcc cc.dhrystone -o dhrystone -DNO_NRV
  124.  
  125. To get one pointer per object padding:
  126. compile using:    gcc cc.dhrystone -o dhrystone -DFAKEVPTR
  127.  
  128. To make =, +=, etc. return *this, not void
  129. compile using:    gcc cc.dhrystone -o dhrystone -DRETREF
  130.  
  131.  
  132. C++ Template handling
  133. ---------------------
  134.  
  135. C++ templates are the first language feature to require more intelligence
  136. from the environment than one usually finds on a UNIX system. Somehow the
  137. compiler and linker have to make sure that each template instance occurs
  138. exactly once in the executable if it is needed, and not at all otherwise.
  139.  
  140. The AT&T C++ translator, Cfront, solved the template instantiation problem
  141. by creating the notion of a template repository, an automatically maintained 
  142. place where template instances are stored.  As individual object files are
  143. built, notes are placed in the repository to record where templates and
  144. potential type arguments were seen so that the subsequent instantiation
  145. step knows where to find them.  At link time, any needed instances are
  146. generated and linked in. 
  147.  
  148. G++ uses a similar mechanism to Cfront's template repository. Source code
  149. using templates should be compiled with the extra switch '-frepo'.
  150. Repository information will then be placed in the directory 'rpo' (provided
  151. you have already created it).  Compiling the source code once with the
  152. '-frepo' flag does not automatically mean that all your template problems
  153. are cured. The source will need to be compiled again so that G++ knows (by
  154. looking in the rpo directory) that certain template functions need compiling.
  155. Only after the second compilation (or maybe third or fourth) should the full
  156. code be produced.
  157.  
  158. The linker front end, ld, also supports the template repository. LD will
  159. look through the rpo directory for files that are relevant to any object
  160. code being linked, check the error messages produced by drlink and decide
  161. whether a recompilation of some of the source is necessary.
  162.  
  163. Supplied is a C++ source called cc.template.  A successful compilation
  164. will need to use the template repository features. There are two methods
  165. to compiling this:
  166.  
  167. First ensure that the directories 'o' and 'rpo' have been created.
  168.  
  169. Method 1
  170. ^^^^^^^^
  171.  
  172. Initially compile the source, g++ will create the object file, o.template
  173. and the repository file, rpo.template. Note that the '-c' switch must
  174. always be used with '-frepo'.
  175.  
  176. *gcc -c cc.template -frepo
  177.  
  178. Use LD, to link the source.
  179.  
  180. *ld -o template o.template gcc:o.libgcc unix:o.unixlib
  181.  
  182. The first link stage will fail because some of the template functions have
  183. not been instantiated. LD will read rpo.template and determine that
  184. cc.template will need a recompilation.
  185.  
  186. On the second compilation, the C++ compiler will use the information in
  187. rpo.template to decide which functions will need compiling.
  188.  
  189. LD will then try and re-link o.template and should complete successfully.
  190.  
  191.  
  192. Method 2
  193. ^^^^^^^^
  194.  
  195. For users who do not trust the facility provided by LD, the process can
  196. be done by hand - we simply compile each source twice:
  197.  
  198. *gcc -c cc.template -frepo
  199. *gcc -c cc.template -frepo
  200. *drlink -o template o.template gcc:o.libgcc unix:o.unixlib
  201.  
  202. You should notice that o.template grows between the first and second
  203. compilations of cc.template.
  204.  
  205.  
  206. However, using LD does have the additional side effect that undefined
  207. symbols are automatically demangled before being display on screen.
  208.  
  209.  
  210. C++ name demangler
  211. ------------------
  212.  
  213. To avoid link problems with overloaded functions, C++ consistently mangles
  214. function names. However, it is not always obvious what the original name
  215. was.
  216.  
  217. The program, 'demangle' should solve this problem. Usage is fairly simple:
  218.    *demangle <symbol> [<symbol>...]
  219. each symbol you wish to have demangled, you pass on the command line. For
  220. example:
  221.  
  222.   *demangle __aml__7IntegerRC7Integer _substr__9BitStringii
  223. returns the output:
  224.   Integer::operator*=(Integer const &)
  225.   BitString::_substr(int, int)
  226.  
  227. Constructors and destructors:
  228.  
  229.   *demangle _GLOBAL_.D.__rtti_get_node_type__C9type_info
  230. returns the output:
  231.   global destructors keyed to type_info::__rtti_get_node_type(void) const
  232.  
  233.  
  234. Functions compile with Run-Time Type Identification are also properly
  235. demangled:
  236.  
  237.   *demangle __17__class_type_infoPCcPP9type_infoPiT3PQ217__class_type_info11access_modei
  238.  
  239. returns the output:
  240.   __class_type_info::__class_type_info(char const *, type_info **, int *,
  241. int *, __class_type_info::access_mode *, int)
  242.  
  243.  
  244. As said previously, the front end linker 'ld' also contains the demangler
  245. software. Output from drlink or link will be presented in a demangled form.
  246.  
  247.  
  248. Predefines
  249. ----------
  250.  
  251. In addition to the ones defined by the GCC front end, GNU C++ also
  252. supplies '__GNUG__'.
  253.  
  254.  
  255. Known problems
  256. --------------
  257.  
  258. If you find a bug then please read the file docs.bugs for what to do if
  259. you have found a bug.
  260.  
  261. Here is a list of all problems that I know of:
  262.  
  263. G++ 2.4.5 produces incompatible code with 2.7.2 and that is simply that.
  264.  
  265.  
  266. Known Restrictions
  267. ------------------
  268.  
  269. Non-local gotos are not implemented for functions within functions. This is
  270. being worked on, when I have the time.
  271.  
  272. Exception handling is not supported.
  273.  
  274.  
  275. Contacting me
  276. -------------
  277.  
  278. I can be contacted by e-mail at: nickb@digibank.demon.co.uk
  279.  
  280. However, if there is no response from that address I can be contacted
  281. through Simon Callan: gcc@callan.demon.co.uk.
  282.