Frequently Asked Questions about "Mastering Object-Oriented Design"

  1. What is the newest version of ChiLib, and how do I get it?

    The current version is ChiLib version 1.05. This version includes support for Unix/Linux with g++ and limited support for X11.

  2. How do I know what version of ChiLib I have now?

    Look at the time stamps of the files. The time (1.00, 1.01, 1.02 etc.) gives the version number, the date the release date of the version.

  3. How can I get more information on the ChiLib classes?

    Actually, this information was supposed to be in the book but got axed in the last minute because the book was already getting longer than originally planned. You can now find the documentation in the CHILIB.TXT file on the disk in the back of the book. Even better, thanks to the excellent work of Tim Balls at Leeds Metropolitan University, the documentation is now available in HTML format.

  4. How can I avoid spurious compiler-specific error messages?

    Make sure that you define the appropriate compiler flags:

    Compiler #define
    Microsoft 2.1 CHI_MC21
    Microsoft >= 4.0 CHI_MC40
    Borland/Turbo 3.0 CHI_BC30
    Borland 3.1 CHI_BC31
    Borland 4.0 CHI_BC40
    Borland/Turbo 4.5 CHI_BC45
    Borland >= 5.0 CHI_BC50
    Symantec >= 7.0 CHI_SC70
    Watcom >= 10.0 CHI_WC10
    Gnu g++ CHI_GCC
    That is, add a line such as #define CHI_MC40 above the first #include, or alternatively, add the identifier to the "defined macros" list of your compiler. Instructions for that vary from one development environment to another.
  5. How can I compile Win 32 programs (e.g. Microsoft Visual C++)?

    Get version 1.04 or above from this web page. Be sure to #define CHI_WIN32.

  6. Why does Borland 4.5/Turbo 4.5 report an "internal error"?

    Borland 4.5 dies with an internal error in some perfectly legal constructs in some Chilib files. In ChiLib 1.01 and above, you can #define CHI_BC45 to switch to a workaround. In ChiLib 1.00, you must do this manually. Two files are affected, chishape.cpp and gedfrmwk.cpp. Instead of writing

       fig.append(new Chi_Rectangle(Chi_Point(0.1, 2.2), Chi_Point(1.9, 3.8)));
       fig.append(new Chi_FilledRect(Chi_Point(0.2, 4.1), Chi_Point(1.8, 5.9),
          Chi_GraphicsContext::XDIAG_BRUSH));
       fig.append(new Chi_Segment(Chi_Point(0.1, 6.2), Chi_Point(1.9, 7.8)));
    
    in chishape.cpp, put the points into separate variables
       Chi_Point p2 = Chi_Point(1.9, 3.8);
       fig.append(new Chi_Rectangle(Chi_Point(0.1, 2.2), p2));
       p2 = Chi_Point(1.8, 5.9);
       fig.append(new Chi_FilledRect(Chi_Point(0.2, 4.1), p2,
          Chi_GraphicsContext::XDIAG_BRUSH));
       p2 = Chi_Point(1.9, 7.8);
       fig.append(new Chi_Segment(Chi_Point(0.1, 6.2), p2));
    
    The same is necessary in gedfrmwk.cpp. Replace
       _button_rect = Chi_Rectangle(Chi_Point(0, 0), Chi_Point(1, r.ybottom()));
    
    with
       Chi_Point p2 = Chi_Point(1, r.ybottom());
       _button_rect = Chi_Rectangle(Chi_Point(0, 0), p2);
    
  7. Why does Borland/Turbo C++ crash with an "IDE: Unexpected termination" error in the keyboard driver DLL?

    No, Chilib does not reprogram the keyboard controller. This is a problem with precompiled headers. The Borland precompiled header parser crashes when it encounters constructs in header files that differ from those found in the plain vanilla system headers. Apparently the mdgen generated Chilib headers make the parser throw a fit. Until Borland engineers a parser that works on all headers, instead of hacking one that works on those they know about, turn off precompiled headers.

  8. Why do I get an error "_TEXT segment exceeds 64K"?

    No, you didn't write more than 64K worth of comment text. Try switching to large memory model. That works in 99% of the cases. By the way, the TEXT segment is the code segment.

    What if you are one of the few unlucky ones who gets a _TEXT overflow even in large memory model? The reason is template instantiation. Borland and Symantec generate all member functions of all templates in your code, and if you have lots of different templates in one source file (e.g. arrays of ten or more different types) you can get that overflow. Remedy 1: Switch to 32-bit mode. 2. Use manual template instantiation.

  9. Why does my graphics program crash?

    For graphics programs, you must define one of CHI_BGI, CHI_WIN, etc. With ChiLib 1.0, your graphics program will crash if none of these is defined. With ChiLib 1.01 and up, it won't compile.

  10. Why do I get an assertion failure "ph != 0" in Chi_String?

    If another part of your program corrupts the internal data strucures of the reference counted strings, this may happen. In all known cases, this was the consequence of buggy user code, not a bug in ChiLib.

  11. Why can't I make a Chi_Array of numbers, pointers and certain classes?

    You have a compiler that does not correctly deal with explicit destructors in templates, such as Microsoft 2.0 or 2.1 or Borland 3.0. Remedy: Use Chi_NumArray or Chi_PtrArray. For arrays of classes, add a do-nothing destructor to your class.

  12. What about the Macintosh?

    Thanks to Professor Hamilton Richards at the University of Texas at Austin (ham@cs.utexas.edu) for a set of files that implement a graphics context class on the Mac and that add a few functions missing from the Metrowerks compiler. The files are zipped together as CHI_MAC.ZIP.

  13. How can I get the coding guidelines in electronic form?

    The file MOODAPP2.RTF contains the coding guidelines in RTF format. You can modify this file for use in any class that uses the Mastering Object-Oriented Design in C++ book as a required text. Any other use, for example for corporate or university style guides, requires written permission from the copyright holder, and payment of a fee.

Back to Cay Horstmann's home page.