home *** CD-ROM | disk | FTP | other *** search
/ BURKS 2 / BURKS_AUG97.ISO / BURKS / LINUX / HOWTO / mini / comeau.txt < prev    next >
Text File  |  1997-07-07  |  9KB  |  262 lines

  1. //
  2. // The Linux Comeau C++ 4.0 HOWTO
  3. // Mark Swanson <ag010@freenet.carleton.ca>
  4. // v0.3, May 16,1997
  5. //
  6. // The Comeau Computing site is:
  7. // http://www.comeaucomputing.com
  8. //
  9.  
  10.  
  11. This document covers how to set up Comeau C++ (herin 
  12. referenced as "como") under Linux. It gives an overview of compiling,
  13. linking, running and debugging programs under it. It explains how to
  14. install and use the latest HP STL (Standard Template Library) reference code
  15. as well as SGI's (more advanced) STL.
  16.  
  17. This document is not a detailed feature comparison between g++ and como.
  18. Anyone who wishes to do this comparison for themselves can get a list
  19. of g++ bugs from ftp://ftp.cygnus.com/pub/g++/g++-bugs/README and compare
  20. them to the list of known bugs in como.
  21. (No one has had the time to create -except for what's mentioned in this FAQ -
  22. a bug list for como. The only problem with it that I know of is it doesn't
  23. have a 100% working iostreams library yet. )
  24.  
  25. ======================================================================
  26. ======================================================================
  27. PART 0  DEPENDENCIES
  28.  
  29. 0.0  You might have to use GCC2.7.2.1 or greater.
  30.  
  31. 0.1  You SHOULD install libg++2.7.2.1 and use the como
  32.      iostream library libiostreamcomo.a(283K) to get iostreams working.
  33.  
  34.      <TODO> Has como compiled/made available the more stable library yet?
  35.             Will it always be called libcomodios.a?
  36.  
  37.      The *catch* here is that if you wish to use the SGI or HP STL libraries
  38.      you won't want to use the STL include files found in /usr/include/g++.
  39.      You can make sure you don't by doing the following:
  40.  
  41.      cd /usr/include/g++
  42.      mkdir gnustl
  43.      mv  algo.h algobase.h alloc.h bool.h bvector.h defalloc.h deque.h function.h heap.h iterator.h list.h map.h multimap.h multiset.h pair.h set.h stack.h tempbuf.h tree.h vector.h gnustl
  44.      
  45.  
  46.      Please send me an email if you've got it working on something other
  47.      than the 2.7.2.1 release of g++.
  48.      
  49. 0.2  I recommend installing libc5.4.23 or greater. I had trouble with earlier
  50.      versions of libc. Symptoms include running out of virtual memory when
  51.      compiling small programs. I suspect something in the include files
  52.      but since upgrading solved my problem I haven't really looked into it.
  53.      
  54.      Again, keep me updated me on this.
  55.  
  56.  
  57. 0.3  You can find the binary/source distributions of the above packages at:
  58.      ftp://ftp.tsx-11.mit.edu/pub/linux/packages/GCC
  59.  
  60.  
  61. 0.4  Remember to follow the instructions on the Comeau Computing patch page:
  62.      http://www.comeaucomputing.com
  63.      You MUST do this before reading anything else in this document!
  64.  
  65.  
  66. =====================================================================
  67. PART I  MODIFICATIONS TO GCC INCLUDE FILES
  68.  
  69.  
  70. 1.0  stdarg or vararg replacement code
  71.         Use the como supplied stdarg.h file. You should have already done
  72.         this. You were supposed to follow the instructions on the patch
  73.         page at step 0.5.
  74.  
  75. 1.1  /usr/include/errno.h line 34.
  76.         It's an extern "C" problem. Improperly defined in the header file.
  77.         We need to move the following lines:
  78.  
  79.            #ifdef  __USE_BSD
  80.            extern int sys_nerr;
  81.            extern char *sys_errlist[];
  82.            #endif
  83.            #ifdef  __USE_GNU
  84.            extern int _sys_nerr;
  85.            extern char *_sys_errlist[];
  86.            #endif 
  87.  
  88.         to just below the __BEGIN_DECLS line. If you don't do this, then these
  89.         definitions will have a different linkage specification than the
  90.         ones in /usr/include/stdio.h. This file is at fault.
  91.  
  92. 1.2     /usr/lib/gcc-lib/iX86-linux/2.7.2.1/include/stddef.h ~line 305.
  93.         This section #defines NULL to a void * which is wrong. Change the
  94.         section:
  95.  
  96.         /* A null pointer constant.  */
  97.  
  98.         // Commented out for Como
  99.         //#if defined (_STDDEF_H) || defined (__need_NULL)
  100.         //#undef NULL        /* in case <stdio.h> has defined it. */
  101.         //#define NULL ((void *)0)
  102.         //#endif    /* NULL not defined and <stddef.h> or need NULL.  */
  103.         //#undef    __need_NULL
  104.        
  105.         to look like:
  106.  
  107.         // Added for como
  108.         #ifndef NULL
  109.             #ifdef __cplusplus
  110.                 #define NULL 0
  111.             #else
  112.                 #define NULL ((void *) 0)
  113.             #endif
  114.         #endif
  115.         // end of 'Added for como'
  116.  
  117. 1.3  /usr/lib/gcc-lib/i486-linux/2.7.2.1/include/syslimits.h 7
  118.      
  119.         #include_next is a gcc'ism. Change this to a normal include.
  120.  
  121.     /usr/lib/gcc-lib/i486-linux/2.7.2.1/include/limits.h 112
  122.         
  123.         Comment out this next line.
  124.  
  125.         //#include_next <limits.h>  /* recurse down to the real one */
  126.  
  127.         
  128. ========================================================================
  129. PART II  STL ISSUES
  130.  
  131. 2.1  How to get HP's or SGI's latest STL code.
  132.  
  133.      The instructions for getting HP's or SGI's STL code are given on
  134.      Comeau's WWW site.
  135.  
  136.  
  137. 2.2  How to modify the HP STL to get rid of a small warning message.
  138.      (new operator and throw() exception specification)
  139.  
  140.      In defalloc.h: 26
  141.         Comment it out. The specification is already in the new.h provided
  142.         by Comeau Computing.
  143.  
  144.  
  145. =====================================================================
  146. PART III  MICROSOFT FILE FORMAT COMPATABILITY
  147.  
  148. 3.0  Compiling files with MS-DOS line termination
  149.      Como has a version of their compiler available for Linux that handles
  150.      MS-DOS CRLF style line terminations. Comeau Computing has stated that
  151.      this will be a standard option in the free upgrades. Until then, I'm
  152.      sure they will make it available to those who ask.
  153.  
  154.  
  155. =====================================================================
  156. PART IV  WORKING AROUND GNU SPECIFIC COMPILER OPTIONS
  157.  
  158. 4.1  __attribute__
  159.  
  160.      In assert.h you will more than likely run into this problem. The fix is
  161.      simply: delete the __attribute__((xxx)); line and place the ';' character
  162.      at the end of the line above it.
  163.  
  164. 4.2  Macros with (...) arguments
  165.  
  166.      Take the following GNU macro:
  167.         #define TRACE(x...)
  168.      
  169.      The como preprocessor doesn't allow macros with ... arguments. Use 
  170.      functions instead.
  171.  
  172.  
  173. =======================================================================
  174. PART V  IOSTREAMS
  175.  
  176. 5.0  iostreams.h
  177.  
  178.      Comeau Computing along with other individuals on the net (myself
  179.      included) are working on making gnu iostreams compile under como.
  180.      We need to get around some gnu specific vtable mangling problems.
  181.      A version of iostreams that works except for fstreams and streambuf
  182.      code is available from the Comeau web site.
  183.  
  184. =======================================================================
  185. PART VI  DEBUGGING WITH GDB
  186.  
  187. 6.0  Using GDB with como
  188.      
  189.      This works to some extent but not fully. You can start debugging your
  190.      application, display variables etc., but in my static callback
  191.      functions gdb can only display some of the functions local variables...
  192.      incorrectly. This is a g++ name mangling problem. The GNU debugger
  193.      expects to be debugging code compiled with a GNU compiler which uses
  194.      a different name mangling scheme.
  195.  
  196. 6.1  Let me know if there is another debugger that would work better!
  197.      (And cc support@comeaucomputing.com as well.)
  198.  
  199. 6.2  One thing you can do is 'info local' at the point where you wish to
  200.      view the contents of your variables. Take the following source code
  201.      for example:
  202.  
  203.      #include <stdio.h>
  204.      int main()
  205.      {
  206.          int a=0, b=1;
  207.          printf("a=%d, b=%d\n", a, b);
  208.          return 0;
  209.      }
  210.      
  211.      After compiling with 'como -g test.cxx' we start gdb with 'gdb a.out'.
  212.      
  213.      (Next we break on the printf() line)
  214.      (gdb) break 5
  215.  
  216.      (Now run the little program)
  217.      (gdb) run
  218.  
  219.      (gdb) info local
  220.      __1044_6_a = 0
  221.      __1044_11_b = 1
  222.  
  223.      *** You were expecting to see a = 0 not __1044_6_a = 0 ***
  224.      * Don't Panic! * :-) instead of:
  225.  
  226.      (gdb) print a
  227.  
  228.      you have to:
  229.  
  230.      (gdb) print __1044_6_a
  231.  
  232.      This is a name mangling problem and there is no solution for it right
  233.      now. I'm sure Comeau Computing will publish their name mangling rules;
  234.      then you can write a patch for gdb. Let me know when you do:-)
  235.  
  236. ================================================================