home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c081_11 / 8.ddi / DOC.ZIP / HELPME!.DOC < prev    next >
Encoding:
Text File  |  1991-02-13  |  40.1 KB  |  914 lines

  1.               Borland C++: ANSWERS TO COMMON QUESTIONS
  2.  
  3.  
  4.  G e t t i n g     S t a r t e d
  5.  ----------------------------------------------------------------------
  6.  Q. How do I install Borland C++?
  7.  A. Run the INSTALL program from the INSTALL/HELP disk. To start
  8.     the installation, change your current drive to the one that
  9.     has the install program on it and type INSTALL. You will be
  10.     given instructions in a box at the bottom of the screen for
  11.     each prompt. For example, if you will be installing from
  12.     drive A:, type:
  13.  
  14.        A:
  15.        INSTALL
  16.  
  17.     At this point, the INSTALL program will appear with menu selections
  18.     and descriptions to guide you through the installation process.
  19.  
  20.  Q. How do I run Borland C++?
  21.  A. After you have installed Borland C++, type "BC" from the DOS
  22.     prompt and you're ready to go.
  23.  
  24.  Q. What is the difference between BC.EXE and BCC.EXE?
  25.  A. The Borland C++ package comes with two compilers, an Integrated
  26.     Development Environment (IDE) named BC.EXE and a command-line
  27.     compiler named BCC.EXE. The IDE combines the command-line compiler
  28.     with an integrated editor, linker, debugger, and other useful
  29.     features (such as pop-up and pull-down menus, full keyboard and
  30.     mouse support, and so on). The command-line version runs from the
  31.     DOS command line. Please refer to the Borland C++ User's Guide for
  32.     details on using both systems.
  33.  
  34.  Q. What is a configuration file?
  35.  A. A configuration file tells Borland C++ what options to default to
  36.     and where to look for its library and header files. BC.EXE
  37.     looks for a configuration file named TCCONFIG.TC, and BCC.EXE
  38.     looks for a file named TURBOC.CFG.
  39.  
  40.  Q. How do I create a configuration file?
  41.  A. When you run the INSTALL program it creates a configuration
  42.     file named TURBOC.CFG for BCC.EXE. This file is just an
  43.     ASCII file, which you can change with any text editor. It
  44.     contains the path information for the library and header
  45.     files for BCC.EXE to use. The INSTALL program does not
  46.     create a TCCONFIG.TC file for BC.EXE because it installs
  47.     the directory information directly into BC.EXE. You can
  48.     create a configuration file for BC.EXE by running Borland C++,
  49.     setting your options however you want to set them, and
  50.     typing Alt-O/S.
  51.  
  52.  C o m m o n   C + +   Q u e s t i o n s
  53.  ----------------------------------------------------------
  54.  
  55.  Q: When linking C or Assembly language modules with C++ modules I get
  56.     undefined symbol errors at link time.  It appears that none of the C
  57.     or Assembly public symbols can be found.
  58.  A: C++ is a strongly typed language.  In order to support the language
  59.     to its fullest, Borland C++ must attach information to the symbols
  60.     generated for function names and variables.  When this is done, the
  61.     symbol will no longer match the standard C style function name.  In
  62.     order to link correctly, the compiler must be notified that the symbol
  63.     is declared in an external module without type information tacked on
  64.     to the symbol.  This is done by prototyping the function as type
  65.     extern "C".   Here is a quick example:
  66.        extern "C" int normal_c_func( float, int, char );  // name not altered
  67.        void cplusplus_function( int );  // name altered
  68.     See related comments under Linker Errors and in the Paradox Engine
  69.     question in this section. There is also more on extern "C" in the
  70.     Borland C++ Programmer's Guide, Chapter 1.
  71.  
  72.  Q. Classes with static data members are getting linker errors ("undefined").
  73.  A. This code is built into Turbo C++ 1.0 but not in Borland C++ 2.0.  In the
  74.     1.0 compiler, static members without definitions were given a default value
  75.     of 0.  This default definition will no longer be made in the 2.0 compiler.
  76.     The programmer must now give an explicit definition for each static member.
  77.     Here is a quick example:
  78.        class A
  79.        {
  80.       static int i;
  81.        };
  82.     A linker error saying that A::i is not defined will result unless the
  83.     source also contains a line such as:
  84.        int A::i = 1;
  85.  
  86.  Q. What potential problems can arise from typecasting a base class pointer
  87.     into a derived class pointer so that the derived class's member functions
  88.     can be called?
  89.  A. Syntactically this is allowable. There is always the possibility of
  90.     a base pointer actually pointing to a base class. If this is
  91.     typecast to a derived type, the method being called may not exist
  92.     in the base class. Therefore, you would be grabbing the address of
  93.     a function that does not exist.
  94.  
  95.  Q: What's the difference between the keywords STRUCT and CLASS?
  96.  A: The members of a STRUCT are PUBLIC by default, while in CLASS,
  97.     they default to PRIVATE. They are otherwise functionally equivalent.
  98.  
  99.  Q: I have declared a derived class from a base class, but I can't access any
  100.     of the base class members with the derived class function.
  101.  A: Derived classes DO NOT get access to private members of a base class.
  102.     In order to access members of a base class, the base class members must
  103.     be declared as either public or protected. If they are public, then
  104.     any portion of the program can access them. If they are protected, they
  105.     are accessible by the class members, friends, and any derived classes.
  106.  
  107.  Q: How can I use the Paradox Engine with C++?,
  108.  A: Because the Paradox Engine functions are all compiled as C functions,
  109.     you will have to assure that the names of the functions do not get
  110.     "mangled" by the C++ compiler. To do this you need to prototype the
  111.     Engine functions as extern "C". (Name mangling and the use of extern "C"
  112.     are both described in detail in Chapter 1 of the Borland C++
  113.     Programmer's Guide.) In the pxengine.h header file insert the following
  114.     code at the lines indicated.
  115.  
  116.        /* inserted at line # 268 */
  117.        #ifdef __cplusplus
  118.        extern "C" {
  119.        #endif
  120.  
  121.        /* inserted at line # 732, just before the final #endif */
  122.        #ifdef __cplusplus
  123.        }
  124.        #endif
  125.  
  126.  Q: I have a class that is derived from three base classes. Can I insure that
  127.     one base class constructor will be called before all other constructors?
  128.  A: If you declare the base class as a virtual base class, its constructor
  129.     will be called before any non-virtual base class constructors. Otherwise
  130.     the constructors are called in left-to-right order on the declaration
  131.     line for the class.
  132.    
  133.  Q: Are the standard library I/O functions still available for use with
  134.     the C++ iostreams library?
  135.  A: Yes, using
  136.  
  137.        #include <stdio.h>
  138.  
  139.     functions such as printf() and scanf() will continue to be
  140.     available.
  141.  
  142.  Q: When debugging my program in Turbo Debugger, I notice that none of my
  143.     inline functions are expanded inline. Instead, they are all done as
  144.     function calls.
  145.  A: Whenever you compile your program with debugging information included,
  146.     no functions are expanded inline. To verify that your inline functions
  147.     are indeed expanding inline, compile a module with the -S flag of the
  148.     command-line compiler, then examine the .ASM file that is generated.
  149.  
  150.  Q. In C++, given two variables of the same name, one local and one global,
  151.     how do I access the global instance within the local scope?
  152.  A. Use the scope (::) operator.
  153.  
  154.        int x = 10;
  155.        for(int x=0; x < ::x; x++)
  156.        {
  157.            cout << "Loop # " << x << "\n"; // This will loop 10 times
  158.        }
  159.  
  160.  Q. Will the following two functions be overloaded by the compiler, or
  161.     will the compiler flag it as an error? Why?
  162.         void test( int x, double y);  &  int test( int a, double b);
  163.  A. The compiler will flag this as a redeclaration error because
  164.     neither return types nor argument names are considered when determining
  165.     unique signatures for overloading functions. Only number and type
  166.     of arguments are considered.
  167.  
  168.  Q. If I pass a character to a function which only only accepts an int,
  169.     what will the compiler do? Will it flag it as an error?
  170.  A. No. The compiler will promote the char to an int and use the integer
  171.     representation in the function instead of the character itself.
  172.  
  173.  Q. I was trying to allocate an array of function pointers using the new
  174.     operator but I keep getting declaration syntax errors using the following
  175.     syntax:  new int(*[10])();   What's wrong?
  176.  A. The new operator is a unary operator and binds first to the int keyword
  177.     producing the following:  (new int) (*[10])();
  178.     You need to put parentheses around the expression to produce the
  179.     expected results:  new (int (*[10]());
  180.  
  181.  Q. What are inline functions? What are their advantages? How are they
  182.     declared?
  183.  A. An inline function is a function which gets textually inserted by
  184.     the compiler, much like macros. The advantage is that execution time
  185.     is shortened because linker overhead is minimized. They are declared
  186.     by using the inline keyword when the function is declared:
  187.  
  188.        inline void func(void) { cout << "printing inline function \n"; }
  189.  
  190.     or by including the function declaration and code body within a class:
  191.  
  192.        class test
  193.        {
  194.        public:
  195.        void func(void) { cout << "inline function within a class.\n"}
  196.        };
  197.  
  198.  Q. If I don't specify either public or private sections in a class,
  199.     what is the default?
  200.  A. In a class, all members are private by default if neither public nor
  201.     private sections are declared.
  202.  
  203.  Q. What does the _seg modifier do?
  204.  A. Using _seg cause a pointer to become a storage place for a
  205.     segment value, rather than an offset ( or a segment/offset ).
  206.     For instance, if "int _seg *x" contains the value 0x40,
  207.     then when you use "*x", the value pointed to will be at
  208.     segment 0x40, offset 0. If you add a value to the pointer,
  209.     the value is multiplied by the size of the pointer type. That
  210.     new value is used as an offset, and is combined with the segment
  211.     value contained in the pointer. For instance,
  212.  
  213.        int _seg *x;
  214.        int value;
  215.  
  216.        x = (int _seg *)0x40;
  217.        value = *(x + 20);
  218.  
  219.     value is assigned the value of the integer at 0x40:0x28
  220.     (Remember, 20 * sizeof(int) = 40 = 0x28).
  221.  
  222.     You can find a more detailed description of _seg in the Borland C++
  223.     Programmer's Guide, Chapter 6.
  224.  
  225.  Q. Can I statically allocate more than 64K of data in a single module?
  226.  A. Yes. Far data items are now supported:
  227.  
  228.        ...
  229.        char far array1[60000L];
  230.        char far array2[60000L];
  231.        ...
  232.  
  233.     For arrays larger than 64k use:
  234.  
  235.        char huge array3[100000L];
  236.  
  237.  
  238.  Q. Why do I get a "Type name expected" error on my definition of a
  239.     friend class in my new class?
  240.  A  You need to let the compiler know that the label you use for your
  241.     friend class is another class. If you do not want to define your
  242.     entire class, you can simply have "class xxx", where xxx is your
  243.     label.
  244.  
  245.  Q: How can I output hex values in upper case using the iostream libraries?
  246.  A: You need to set the state of the stream using setf(). For example,
  247.  
  248.        #include <iostream.h>
  249.  
  250.        int main(void)
  251.        {
  252.           cout << hex;
  253.           cout << "\nNot upper-case : " << 255;
  254.           cout.setf(ios::upper-case);
  255.           cout << "\nUppercase     : " << 255;
  256.           return 0;
  257.         }
  258.  
  259.  Q. What is the "this" pointer?
  260.  A. "this" is a local variable in the body of a non-static member function.
  261.     It is a pointer to the object for which the function was invoked. It
  262.     cannot be used outside of a class member function body.
  263.  
  264.  Q. Why does a binary member function only accept a single argument?
  265.  A. The first argument is defined implicitly.
  266.  
  267.  Q. What is a friend member function?
  268.  A. Declaring a friend gives non-members of a class access to the
  269.     non-public members of a class.
  270.  
  271.  Q: Looking through the class libraries there are definitions in classes
  272.     which look like:
  273.        class test {
  274.            int funct( void ) const;
  275.        };
  276.     What is the const keyword doing here?
  277.  A: There is a pointer to the object for which a function is called
  278.     known as the 'this' pointer.  By default the type of 'this'
  279.     is  X *const ( a constant pointer).  The const keyword changes the
  280.     type to const X *const ( a constant pointer to constant data ).
  281.  
  282.  Q: I want to use _new_handler and set_new_handler.
  283.  A: Borland C++ supports _new_handler and set_new_handler even though they
  284.     are not explicitly defined in the AT&T 2.0 language specification.
  285.     You can find a discussion of them in Chapter 3 of the Borland C++
  286.     Programmer's Guide. The type of _new_handler is as follows.
  287.         typedef void (*vfp)(void);
  288.         vfp _new_handler;
  289.         vfp set_new_handler( vfp );
  290.  
  291.  Q: I would like to use C++ fstreams on a file opened in binary mode,
  292.     how is this done?
  293.  A: Use ios::binary as the open mode for the file:
  294.         #include <fstream.h>
  295.         ifstream binfile;
  296.         binfile.open("myfile.bin", ios::binary);
  297.  
  298.  Q: How can I get at the DOS file handle associated with my iostream?
  299.  A: Using a combination of member functions fd() and rdbuf() you can
  300.     get at the file handle.
  301.         #include <fstream.h>
  302.         #define fstrno(s)  (((s).rdbuf())->fd())
  303.         ifstream test("test.txt");
  304.         cout << "handle is " << fstrno(test) << '\n';
  305.  
  306.  
  307.  C o m m o n    W i n d o w s   Q u e s t i o n s
  308.  ----------------------------------------------------------------------
  309.  Q. Why isn't my DLL working correctly?
  310.  A. One possibility is that you are not linking in the correct 'cwin'
  311.     library.  If you are building a small model DLL, you should be using
  312.     cwinc, not cwins.  If you are building a medium model DLL, you should
  313.     be using cwinl, not cwinm.  Compact and large models should use cwinc
  314.     and cwinl respectively.
  315.  
  316.  Q. Why isn't my program working correctly?  I'm getting a message box from
  317.     Windows saying "Unrecoverable Application Error".
  318.  A. One possible answer is that the program was not built correctly.
  319.     For example, the linker did not get the correct information to export
  320.     functions.  Diagnostic messages from the linker could indicate this.
  321.     To check that you have built your program on DLL as expected, review
  322.     the section in Chapter 3 of the User's Guide that deals with exports.
  323.     This section has a table with 8 columns describing the possible
  324.     combinations you might have used to build your program.  If the setup
  325.     of your program corresponds to one of the last three columns, chances
  326.     are that your program was not built correctly ( or, at least, as you
  327.     intended ). Column 5 corresponds to the 'classical' method of building
  328.     windows programs ( that is, all exports are declared in the module
  329.     definition file ( the .def file )).
  330.  
  331.     The columns that use -WE or -WDE will build 'better' code in sense that
  332.     the compiler will not make 'exportable' any functions that it does not
  333.     actually export.  However, it is here that many people will run into
  334.     problems.  If you have any functions declared as exports in the .def
  335.     file but the module is compiled with -WE or -WDE, then you probably
  336.     have built the program incorrectly (the function will be exported only
  337.     if it is preceded by _export in the source code).
  338.  
  339.  Q. How do I use the _export key word?
  340.  A. Put the "_export" immediately before the function name in the function
  341.     declaration to export that function.
  342.     Here is a quick example:
  343.        long FAR PASCAL _export func(void) {...}
  344.  
  345.  Q. I tried to run <filename>.EXE under Windows 3.0. A window popped up
  346.     titled 'Application Compatibility Warning', and said,
  347.        'The application you are about to run... '.
  348.  A. You did not run the resource compiler, i.e.,
  349.        C:> RC <filename>.RC
  350.     at the command line at the time you created this program.  If you plan
  351.     to create a menu with menuitems in your window, you will need to create
  352.     an RC file.  If your program has menus and is a simple window that does
  353.     not need an RC file, run the resource compiler with <filename>.EXE.
  354.  
  355.  Q. I ran the resource compiler and got the error message:
  356.        RC: fatal error RW1010: Could not open <filename>.RC
  357.  A. You do not have an RC file created for <filename>. If you do not need
  358.     an RC file for this particular application, run the resource compiler
  359.     with <filename>.EXE.  This will create an application that will be able
  360.     to run on Windows 3.0.
  361.  
  362.  Q. I created a Microsoft Windows application and then went to run it
  363.     under Windows.  I entered the name in the Run window and pressed return
  364.     (or clicked the mouse cursor over the OK button).  I waited for my window
  365.     from my application to come up, but it never did.
  366.  A. If you have Turbo Debugger for Windows, run it in here and step through
  367.     it to see if it reaches the Windows function 'ShowWindow()'.  If it
  368.     does not, check the first parameter in the Windows function
  369.     'CreateWindow()' to see if it is the same value as in the WNDCLASS
  370.     structure member lpszClassName.  In other words, check to see if they
  371.     are spelled exactly the same.  This is case sensitive.
  372.  
  373.  Q. I run BCC.EXE and then RC.EXE and get the error message:
  374.        RC: warning RW4002: Non-discardable segment # set to PRELOAD
  375.  A. If # equals 1, then you forgot the CODE PRELOAD statement in your
  376.     <filename>.DEF file.  If # equals 2, then you forgot the DATE PRELOAD
  377.     statement in your <filename>.DEF file.  If two of these warnings occur,
  378.     you have either forgotten both CODE and DATA statements or have not
  379.     created a <filename>.DEF file.
  380.  
  381.  Q. I run RC.EXE and get the error message:
  382.        RC: fatal error RW1030: <filename>.EXE: Unable to open
  383.  A. You need to list more information after the CODE statement in your
  384.     <filename>.DEF file (that is, CODE PRELOAD).
  385.  
  386.  Q. I run BCC.EXE and get the error message:
  387.        Fatal: <filename>.def (<line #>): syntax error
  388.  A. Check your DATA statement on line number # in <filename>.DEF for the
  389.     correct code (that is, DATA PRELOAD).
  390.  
  391.  Q. I run the Borland C++ IDE directly from Windows, rather than from the
  392.     DOS command line.  It does not get a DOS path and cannot find the
  393.     resource compiler RC, as that transfer item does not have an explicit
  394.     path listed.
  395.  A. Either run from a DOS shell (i.e., start DOS, then start Borland C++) or
  396.     modify the path for the transfer item so it explicitly knows where RC.EXE
  397.     lives.
  398.  
  399.  
  400.  I n t e g r a t e d    E n v i r o n m e n t
  401.  ----------------------------------------------------------------------
  402.  Q: Why doesn't my mouse work well with Borland C++?
  403.  A: The most likely cause is that you are using an older mouse driver. You'll
  404.     need to get a newer version.  Check the list on page 3 of the Getting
  405.     Started Manual for most common mouse drivers.  In addition to that list:
  406.         Logitech driver 4.0+ is needed to use the mouse in 43/50 line mode.
  407.         Genius driver version 9.0+ is needed for compatability.
  408.  
  409.  Q. Why is Borland C++ not able to find any of my #include files?
  410.  A. The compiler searches for include files in the Borland C++ Include
  411.     Directories path. You can specify this path through the
  412.     Options|Directories menu. The INSTALL program initially sets this
  413.     path to the directory where it copied all the Borland C++ *.h files.
  414.  
  415.  Q. Why do I get the message:
  416.        Linker Error: Unable to open input file 'C0x.OBJ'
  417.  A. The linker searches for Borland C++ start-up and library files in the
  418.     Borland C++ Library Directories path. You can specify this path through
  419.     the Options|Directories menu. The INSTALL program initially sets this
  420.     path to the directory where it copied the start-up and library files.
  421.  
  422.  Q. How do I get Borland C++ to link in my own libraries or use multiple
  423.     source files?
  424.  A. Borland C++'s Project facility is designed to allow you to work with
  425.     multiple files.
  426.  
  427.  Q. Why does the linker tell me that all the graphics library routines
  428.     are undefined?
  429.  A. The Options|Linker|Graphics Library item must be set ON if
  430.     you are using any Borland C++ graphics functions and have not
  431.     specified GRAPHICS.LIB in a project file.
  432.  
  433.  Q. Why does Borland C++ report "Unable to open include file 'stdarg.h'"
  434.     when I try to #include <stdio.h>?
  435.  A. The most probable reason is that you have exceeded the number
  436.     of files that DOS can have open simultaneously. Add the line
  437.  
  438.        FILES=20
  439.  
  440.     to your DOS CONFIG.SYS file. This allows DOS to open up to 20
  441.     files at the same time. CONFIG.SYS will only be effective after
  442.     you have rebooted your computer. See the IBM DOS Reference
  443.     Manual for details on the CONFIG.SYS file.
  444.  
  445.  Q. I run the Borland IDE directly from Windows, rather than from the
  446.     DOS command line.  It does not get a DOS path and cannot find the
  447.     resource compiler RC, as that transfer item does not have an explicit
  448.     path listed.
  449.  A. Either run from a DOS shell (i.e., start DOS, then start Borland C++)
  450.     or modify the path for the transfer item so it explicitly knows where
  451.     RC.EXE lives.
  452.  
  453.  Q. How do I change the colors of the editor and menus in Borland C++?
  454.  A. The utility BCINST.EXE allows you to customize your colors.
  455.  
  456.  Q. How do I get a listing of my source code to my printer?
  457.  A. From within the Borland C++ editor press Ctrl-K-P. This will
  458.     print a marked block to the printer. If no block is marked,
  459.     this key sequence will print the entire file in your editor.
  460.  
  461.  Q. When I Make, Run, or Trace a program, Borland C++ sometimes goes
  462.     through the compile and link process even when the object files
  463.     are up-to-date.
  464.  A. Borland C++'s MAKE logic works solely on a file's date and time
  465.     stamp. If one of your source files is marked with a date
  466.     that's sometime in the future, the object files that are
  467.     created from it will always be older than the source file,
  468.     and Borland C++ will always try to rebuild the file. You can fix
  469.     this by using TOUCH.COM to set the file to the current date
  470.     and time. You should also make sure that your system's date
  471.     and time are always properly set. TOUCH.COM is documented in
  472.     the file UTIL.DOC.
  473.  
  474.  Q. How come my old Borland C++ project files don't work anymore?
  475.  A. Project files now contain much more information about a project now,
  476.     and hence are no longer stored in ASCII format. To create a project
  477.     file, select PROJECT from the main menu, and follow the menus. To
  478.     convert your old project files to the new format, use the supplied
  479.     utility file PRJCNVT.EXE (documented in UTIL.DOC).
  480.  
  481.  Q. How can I convert my Turbo C 2.0 project files to the new
  482.     format?
  483.  A. There is a conversion utility in your Borland C++ BIN directory
  484.     called PRJCNVT.EXE. This program will perform the conversion.
  485.  
  486.  Q. How come my project file is automatically loaded when I start Borland C++?
  487.     I want to work on a different program.
  488.  A. If there is only one project file in the current directory, Borland C++
  489.     will load and use that one file. If there are no project files, or
  490.     if there are multiple project files, Borland C++ does not automatically
  491.     load one. Go ahead and create a new project.
  492.  
  493.  Q. My right mouse button appears to do nothing. Can I change this so it
  494.     will set breakpoints?
  495.  A. Yes, under the menu for Options|Environment|Mouse there is a
  496.     dialog box for the right mouse button. You can change it to set
  497.     breakpoints, or to do many other things.
  498.  
  499.  Q. How do I get Borland C++ to use extended or expanded memory?
  500.  A. Use the /X option for extended and the /E option for expanded when
  501.     you invoke Borland C++.
  502.  
  503.  Q. How can I find out where my "null pointer assignment" is occurring?
  504.  A. Set a watch on the following expressions:
  505.  
  506.             *(char *)0,4m
  507.             (char *)4
  508.  
  509.     Step through the program. When the values change, the just-executed line
  510.     is the one that is causing the problem.
  511.  
  512.  Q. When I compile my program, I get the following error:
  513.  
  514.        Error: C:\BORLANDC\INCLUDE\STDIO.H: Overlays only supported in
  515.        medium, large, and huge memory models
  516.  
  517.     What is happening?
  518.  A. The Overlay Support option has been selected and does not work
  519.     in the tiny, small, or medium memory models. You can turn this option
  520.     off with:
  521.       Options|Compiler|Code Generation|Overlay Support
  522.    
  523.  Q. When I try to load a new file after editing a file, the first
  524.     file remains on the screen. How do I close the first file?
  525.  A. Use Alt-F3 to close the current file. Also, use F6 to move
  526.     from one file to the next, if there is more than one file
  527.     open at a time.
  528.  
  529.  Q. I'm doing a search and replace operation, and the editor prompts me for
  530.     each replacement. I've selected "Change All", but it still does it.
  531.  A. To disable the prompting, you must unselect the "Prompt on replace"
  532.     option on the left side of the dialog box.
  533.  
  534.  Q. When I try to use the any of the pseudo registers, like _AX, I
  535.     get the error message "Undefined symbol '_AX' in function..."
  536.     when I compile. Why?
  537.  A. You are only allowed to use the pseudo registers in the Borland
  538.     C++ and ANSI modes of the compiler. You can change this setting
  539.     in the Options|Compiler|Source menu.
  540.  
  541.  Q. Since I don't have a mouse, can I still copy blocks of code
  542.     from one file to another?
  543.  A. Yes. You can mark the beginning and end of a block by moving
  544.     to the appropriate area and pressing Ctrl-K-B (mark beginning) and
  545.     Ctrl-K-K (mark end). You can then use the copy and paste commands
  546.     in the Edit menu.
  547.  
  548. Q:  The changes I am making using the BCINST utility are not taking effect.
  549. A:  Any options or colors saved directly to BC.EXE using BCINST.EXE may be
  550.     overridden by the contents of a configuration file or a project file.
  551.     When Borland C++ begins running, it first determines if there is only
  552.     one project file in the current directory.  If there is, this project
  553.     file will automatically be loaded.  Borland C++ will then look for a
  554.     file with a .TC extension in either the current directory or the
  555.     directory in which the Borland C++ executable resides, loading it if
  556.     it can be found. If you haven't done anything to TCCONFIG.TC, you can
  557.     just delete it.
  558.  
  559.  Q: How do I stop all of the files I have ever edited from constantly
  560.     being open when I bring up Borland C++?
  561.  A: By default, Borland C++ saves what is called the desktop configuration.
  562.     This configuration is saved in a file with a .DSK extension.  By deleting
  563.     any files of this type, then entering Options/Environment/Preferences
  564.     and removing the check from 'auto save desktop', you will begin with a
  565.     clean desktop each time you invoke Borland C++.
  566.  
  567.  
  568.  C o m m a n d  -  L i n e    C o m p i l e r
  569.  ----------------------------------------------------------------------
  570.  Q. Why is Borland C++ not able to find any of my #include files?
  571.  A. The compiler searches for include files in the Borland C++ Include
  572.     Directories path. You specify this path with the -I option. The INSTALL
  573.     program initially writes a configuration file (TURBOC.CFG) that
  574.     sets this path to the directory where it copied all the Borland C++
  575.     *.h files.
  576.  
  577.  Q. Why do I get the message:
  578.        Linker Error: Unable to open input file 'C0x.OBJ'
  579.  A. The linker searches for Borland C++ start-up and library files in the
  580.     Borland C++ Library Directories path. You can specify this path with
  581.     the -L option. If you allow BCC to invoke the linker, it will search
  582.     the directories in the configuration file (TURBOC.CFG) written by the
  583.     INSTALL program. If you run TLINK, the configuration file is not read.
  584.  
  585.  Q. Why does the linker tell me that all the graphics library routines are
  586.     undefined?
  587.  A. BCC will not search the graphics library unless you tell it to.
  588.     You should specify the graphics library on the command line. For
  589.     example, to compile BGIDEMO, type
  590.  
  591.        BCC BGIDEMO.C GRAPHICS.LIB<Enter>
  592.  
  593.  Q. I run BCC.EXE and get the error message:
  594.        Fatal: <filename>.def (<line #>): syntax error
  595.  A. Check your DATA statement on line number # in <filename>.def for the
  596.     correct code (that is, DATA PRELOAD).
  597.  
  598.  
  599.  G e n e r a l     I / O
  600.  ----------------------------------------------------------------------
  601.  Q. The '\n' in cprintf() does not return the cursor to the
  602.     beginning of the line. It only moves the cursor down one line.
  603.  A. cprintf() interprets '\n' as a Line Feed. To force the cursor to
  604.     the beginning of the line, manually insert a Carriage Return:
  605.  
  606.       cprintf("\n\r");
  607.  
  608.  Q. How do I print to the printer from a Borland C++ program?
  609.  A. Borland C++ uses a FILE pointer (stdprn) defined in the STDIO.H
  610.     file. You do not need to open stdprn before using it:
  611.  
  612.        #include <stdio.h>
  613.        int main(void)
  614.        {
  615.            fprintf(stdprn, "Hello, world\n");
  616.        }
  617.  
  618.     Note that if your printer is line-buffered, the output is
  619.     flushed only after a '\n' is sent.
  620.  
  621.  Q. I am reading and writing binary files. My program is translating
  622.     the Carriage Return (0x0D) and Line Feed (0x0A) characters. How do
  623.     I prevent this from happening?
  624.  A. Files opened in text mode will translate these characters for
  625.     DOS. To read a file in binary mode, open it in binary mode.
  626.     For example,
  627.  
  628.       #include <stdio.h>
  629.       int main(void)
  630.       {
  631.          FILE *binary_fp;
  632.          char buffer[100];
  633.  
  634.          binary_fp = fopen("MYFILE.BIN", "rb");
  635.  
  636.          fread(buffer, sizeof(char), 100, binary_fp);
  637.  
  638.                     :
  639.       }
  640.  
  641.     The default file mode is text.
  642.  
  643.  Q. Why don't printf() and puts() print text in color?
  644.  A. Use the console I/O functions cprintf() and cputs() for color output.
  645.  
  646.       #include <conio.h>
  647.       int main(void)
  648.       {
  649.           textcolor(BLUE);
  650.           cprintf("I'm blue.");
  651.       }
  652.  
  653.  Q. How do I print a long integer?
  654.  A. Use the "%ld" format:
  655.  
  656.       long int l = 70000L;
  657.       printf("%ld", l);
  658.  
  659.  Q. How do I print a long double?
  660.  A. Use the "%Lf" format.
  661.  
  662.       long double ldbl = 1E500;
  663.       printf("%Lf", ldbl);
  664.  
  665.  
  666.  E x a m p l e   P r o g r a m s
  667.  ----------------------------------------------------------------------
  668.  Q. How do I compile the BGIDEMO program?
  669.  A. 1. Make sure that the following Borland C++ files are in your
  670.        current directory:
  671.  
  672.          BGIDEMO.C
  673.          *.BGI
  674.          *.CHR
  675.  
  676.     2. Run Borland C++.
  677.  
  678.     3. Load BGIDEMO.C into the Editor by pressing F3, then typing
  679.        BGIDEMO<Enter>
  680.  
  681.     3. Go to the Run menu and choose the Run item.
  682.  
  683.  Q. How do I create a COM file?
  684.  A. DOS versions 3.2 and earlier include an EXE2BIN utility that
  685.     converts EXE files to COM files. Users who do not have EXE2BIN can
  686.     use TLINK, the Borland C++ command-line linker, to create a COM file
  687.     instead of an EXE file. Use the /t option. For example:
  688.  
  689.        BCC -mt -lt tiny
  690.  
  691.     will create TINY.COM instead of TINY.EXE.
  692.  
  693.     There are certain limitations in converting an EXE file to a COM
  694.     file. These limitations are documented in the IBM Disk Operating
  695.     System manual under EXE2BIN.
  696.  
  697.     Borland C++'s TINY model is compatible with the COM format, but programs
  698.     that use Borland C++'s floating-point routines cannot be converted to a
  699.     COM file.
  700.  
  701.  
  702.  G r a p h i c s
  703.  ----------------------------------------------------------------------
  704.  Q. Why do I get the error message:
  705.  
  706.        BGI Error: graphics not initialized (use 'initgraph')
  707.  
  708.     when I use a graphics function? My program has already
  709.     called initgraph().
  710.  A. For some reason initgraph() failed. To find out why, check
  711.     the return value of graphresult(). For example:
  712.  
  713.       #include <graphics.h>
  714.       int main(void)
  715.       {
  716.         int gerr;   /* graphics error */
  717.         int gdriver = DETECT, gmode;
  718.  
  719.         /* Initialize graphics using auto-detection and look
  720.            for the .BGI and .CHR files in the C:\BORLANDC directory.
  721.         */
  722.         initgraph(&gdriver, &gmode, "C:\\BORLANDC");
  723.  
  724.         if ((gerr = graphresult()) != grOk)
  725.         {
  726.             printf("Error : %s\n", grapherrormsg(gerr));
  727.             exit(1);
  728.         }
  729.                :
  730.       }
  731.  
  732.  
  733.  M a t h  /  F l o a t i n g    P o i n t
  734.  ----------------------------------------------------------------------
  735.  Q. Why do I get incorrect results from all the math library
  736.     functions like cos(), tan() and atof()?
  737.  A. You must #include <math.h> before you call any of the standard
  738.     Borland C++ math functions. In general, Borland C++ assumes that a function
  739.     that is not declared returns an int. In the case of math functions,
  740.     they usually return a double. For example
  741.  
  742.         /* WRONG */                       /* RIGHT */
  743.                                           #include <math.h>
  744.         int main(void)                    int main(void)
  745.         {                                 {
  746.           printf("%f", cos(0));             printf("%f", cos(0));
  747.         }                                 }
  748.  
  749.  Q. How do I "trap" a floating-point error?
  750.  A. See the signal() and matherr() functions in the Borland C++ Library
  751.     Reference. The signal() function may be used to trap errors in the
  752.     80x87 or the 80x87 emulator. The matherr() function traps errors
  753.     in the Math Library functions.
  754.  
  755.  
  756.  L i n k e r    E r r o r s
  757.  ----------------------------------------------------------------------
  758.  Q. I am linking C functions with C++ functions.  The linker reports that
  759.     all of my C functions are undefined.  Why?
  760.  A. Linking C++ modules with C modules requires the use of a linkage
  761.     specification.  Prototypes for C functions within C++ modules must
  762.     be in one of the following forms:
  763.  
  764.         extern "C" declaration
  765.         extern "C" { declarations }
  766.  
  767.     For example, if a C module contains functions
  768.     "char *SCopy(char*, char*);" and "void ClearScreen(void)", they
  769.     must be declared in a C++ module in one of the following ways:
  770.  
  771.         extern "C" char *SCopy(char*, char*);
  772.         extern "C" void ClearScreen(void);
  773.  
  774.     or
  775.  
  776.         extern "C" {
  777.             char *SCopy(char*, char*)
  778.             void ClearScreen(void);
  779.         }
  780.  
  781.     For further examples, see the standard header files.  For additional
  782.     comment, see Common C++ Questions.
  783.  
  784.  Q. Why do I get the message:
  785.       Linker Error: Unable to open input file 'C0x.OBJ'
  786.  A. See the "Integrated Environment" section above.
  787.  
  788.  Q. Why do I get the message:
  789.       Linker Error: Undefined symbol '_main' in module C0
  790.  A. Every C program must contain a function called main(). This
  791.     is the first function executed in your program. The function
  792.     name must be all in lower case. If your program does not
  793.     have one, create one. If you are using multiple source files,
  794.     the file that contains the function main() must be one of
  795.     the files listed in the Project.
  796.  
  797.     Note that an underscore character '_' is prepended to all
  798.     external Borland C++ symbols.
  799.  
  800.  Q. Why does the linker tell me that all the graphics library
  801.     routines are undefined?
  802.  A. See the "Integrated Environment" and "Command-line Compiler"
  803.     sections above.
  804.  
  805.  Q. What is a 'Fixup overflow'?
  806.  A. See the listing of TLINK error messages in the Borland C++
  807.     User's Guide.
  808.  
  809.  Q. I am linking my own assembly language functions with Borland C++.
  810.     The linker reports that all of my functions are undefined.
  811.  A. Make sure that you have put an underbar character '_' in front of all
  812.     assembly language function names to be called by Borland C++. Your
  813.     assembly language program should be assembled with Case Sensitivity.
  814.  
  815.  Q: I am getting an error out of the linker "segment group exceeds 64K :
  816.     _text".
  817.  A: If you are using the BGIOBJ utility, the default segment into which
  818.     the objects will be place is _text.  You should try using BGIOBJ with
  819.     the /f option to place the resultant objects into a separate segment.
  820.     You will then need to use the functions registerfarbgidriver and
  821.     registerfarbgifont to register the objects for the graphics system.
  822.     See UTIL.DOC for instructions on using these functions.
  823.  
  824.  Q: I am attempting to link Turbo C 2.0 objects into my Borland C++ programs,
  825.     but continually get unresolved external symbols at link time.
  826.  A: The names of many of the "helper" functions have changed from what they
  827.     were in Turbo C 2.0. If you are getting undefined symbols like _LXLSH and
  828.     _FMUL, this is the problem you are running into.  Your best solution is to
  829.     get the source code to the old object modules and recompile with Borland C++.
  830.     The only other possibility would be to extract the helper function objects
  831.     from the Turbo C 2.0 libraries and link them into the Borland C++ program.
  832.  
  833.  Q. I'm porting an application that uses communal variables to C++.
  834.     I've set up the compiler to recognize them, but I still get linker
  835.     errors:
  836.  
  837.       Error: <name> defined in module <a> is duplicated in module <b>
  838.  
  839.  A. C++ doesn't support explicit COMDEFs; you must use static
  840.     variables or switch to C.
  841.  
  842.  O t h e r    Q u e s t i o n s
  843.  ----------------------------------------------------------------------
  844.  Q. How do I change the stack size?
  845.  A. The size of the stack of a Borland C++ program is determined at
  846.     run time by the global variable _stklen. To change the size
  847.     to, for example, 10,000 bytes, include the following line in
  848.     your program:
  849.  
  850.       extern unsigned _stklen = 10000;
  851.  
  852.     This statement must not be inside any function definition.
  853.     The default stack size is 4,096 bytes (4K).
  854.  
  855.  Q. I'm getting a 'Stack Overflow!' message when I run my program.
  856.     How can I work around this?
  857.  A. You may increase the stack size by following the procedure above. Stack
  858.     overflows are usually caused by a large amount of local data or
  859.     recursive functions. You can decrease the amount of stack space
  860.     used by declaring your local variables static:
  861.  
  862.          int main(void)                int main(void)
  863.          {                             {
  864.              char x[5000];     -->          static char x[5000];
  865.                  :                                :
  866.          }                             }
  867.  
  868.     Of course, you should be aware that there are other effects
  869.     that the "static" keyword has, as applied here. See the Borland C++
  870.     Programmer's Guide.
  871.  
  872.  Q. My program comes up with the message 'Null pointer assignment'
  873.     after it terminates. What does this mean?
  874.  A. Before a small-data model Borland C++ program returns to DOS, it will
  875.     check to see if the beginning of its data segment has been corrupted.
  876.     This message is to warn you that you have used uninitialized pointers
  877.     or that your program has corrupted memory in some other way.
  878.  
  879.  Q. Why are .EXE files generated by BC.EXE larger than those generated by
  880.     BCC.EXE?
  881.  A. In the default configuration, BC.EXE includes debugging information in
  882.     the .EXE files that it creates, and BCC.EXE does not. If you don't want
  883.     to produce this debugging information, you can shut it off in the
  884.     Integrated Development Environment by selecting Alt-D|S|N.
  885.  
  886.  Q. Why do I get "declaration syntax error" messages on dos.h?
  887.  A. You have set the "ANSI keywords only" option ON. Keep this option OFF
  888.     when using any keywords specific to Borland C++. See the Borland C++
  889.     Programmer's Guide for a list of keywords.
  890.  
  891.  Q. I have a working program that dynamically allocates memory
  892.     using malloc() or calloc() in small data models (tiny, small,
  893.     and medium). When I compile this program in large data models
  894.     (compact, large, and huge), my program hangs.
  895.  A. Make sure that you have #include <alloc.h> in your program.
  896.  
  897.  Q. I am linking my own assembly language functions with Borland C++.
  898.     But the linker reports that all of my functions are undefined.
  899.  A. See answer above in the "Linker" section.
  900.  
  901.  Q. My far pointers "wrap around" when they are incremented over 64K.
  902.     How do I reference a data object that is greater than 64K?
  903.  A. Use huge pointers.
  904.  
  905.  Q. How do I interface Borland C++ routines to a Turbo Pascal program?
  906.  A. See the example programs CPASDEMO.PAS and CPASDEMO.C on disk.
  907.     These files are packed in the file EXAMPLES.ARC. You will need to
  908.     UNPACK them before using them.
  909.  
  910.  Q. How do I get Clipper to link with Borland C++?
  911.  A. If you are having trouble, contact Nantucket Technical Support.
  912.  
  913.  
  914.