home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / FAQ210B.ZIP / faq / djgppfaq.txt < prev    next >
Encoding:
Text File  |  1997-01-17  |  379.8 KB  |  8,083 lines

  1. START-INFO-DIR-ENTRY
  2. * FAQ: (djgppfaq).           The DJGPP FAQ list.
  3. END-INFO-DIR-ENTRY
  4.  
  5. This is the DJGPP Frequently-Asked Questions List.
  6.  
  7. Copyright (C) 1994, 1995, 1996, 1997 Eli Zaretskii
  8.  
  9. This is the second edition of the FAQ list,
  10. and is consistent with version 2.01 of DJGPP.
  11.  
  12. This FAQ list may be freely distributed with the DJGPP package or any part
  13. thereof, provided this copyright notice is left intact on all copies.
  14.  
  15. DJGPP FAQ List
  16. **************
  17.  
  18.   In DJGPP (see DJGPP overview in Chapter 2), a 32-bit compiler and programming
  19. environment, originally written for Unix machines, meet a 16-bit MS-DOS
  20. operating system.  Programmers who work in this environment have to master a
  21. large body of knowledge from both Unix and MS-DOS, especially if they want to
  22. use some advanced features, like interrupt handling, directly accessing
  23. peripheral devices, etc.
  24.  
  25.   But because the DJGPP project is a product of a group of volunteers, there
  26. isn't always enough time (or patience, or money ;-) to produce documentation
  27. which will describe all the subtle features and pitfalls a user should know
  28. about.  The documentation of DJGPP-specific utilities and issues is therefore
  29. minimal, leaving wide space for confusion, in newcomers and veterans alike,
  30. and making the DJGPP learning curve quite a steep one.
  31.  
  32.   This FAQ list is an attempt to take the sting out of that learning curve, by
  33. supplying solutions for problems which are known to puzzle DJGPP users.
  34. (Another solution would be to pay to DJ Delorie and other people who
  35. developed DJGPP to produce more documentation ;-).
  36.  
  37.   This is Edition 2.10 of the FAQ, last updated 17 January 1997, for DJGPP
  38. Version 2.01.
  39.  
  40.   Another place to look for DJGPP documentation is the DJGPP Knowledge Base, at
  41. this URL:
  42.  
  43.      http://www.delorie.com/djgpp/doc/kb/
  44.  
  45.   Brennan Underwood <brennan@mack.rt66.com> maintains a home page which is
  46. another valuable source for information about DJGPP, at this URL:
  47.  
  48.      http://brennan.home.ml.org/djgpp
  49.  
  50.   You can browse the HTML version of this FAQ list on line at the DJ Delorie's
  51. Web server, at this URL:
  52.  
  53.      http://www.delorie.com/djgpp/v2faq/faq.html
  54.  
  55.   If you browse this FAQ at DJ Delorie's server now, you can get the source
  56. distribution of the FAQ right here, at this URL:
  57.  
  58.      http://www.delorie.com/djgpp/v2faq/faq210s.zip
  59.  
  60. Also available from the DJ's server: FAQ in all the supported formats, at
  61. this URL:
  62.  
  63.      http://www.delorie.com/djgpp/v2faq/faq210b.zip
  64.  
  65.   A previous version of this FAQ was translated into French, e.g.
  66. ftp://ftp.delorie.com/pub/djgpp/v2faq/frfaq.zip, also available through the
  67. WWW, at this URL:
  68.  
  69.      http://www.delorie.com/djgpp/v2faq/frfaq.zip
  70.  
  71.    Table of Contents
  72.    *****************
  73. 1. If You Are In a Hurry
  74. 2. What is DJGPP?
  75. 3.  Hardware and Software Requirements
  76.   3.1 The minimum system requirements for using DJGPP
  77.   3.2 Does it really work under OS/2?
  78.   3.3 Will it work under Windows/NT?
  79.   3.4 Can it run under Linux?
  80.   3.5 Can I run it on a 286?
  81.   3.6 MS-Windows applications and DJGPP
  82.   3.7 What you *should* buy ...
  83.   3.8 What most of us will *actually* buy ...
  84.   3.9 How to configure your system for DJGPP?
  85. 4. Where and What to Download?
  86.   4.1 Where can I get DJGPP?
  87.   4.2 CCT sites
  88.   4.3 How do I download DJGPP?
  89.   4.4 What if I don't know what `FTP' is?
  90.   4.5 What Files to Download?
  91.   4.6 How much disk space will I need?
  92.   4.7 Can I get away with less megabytes?
  93. 5. The DJGPP Documentation
  94.   5.1 Where are the documentation files?
  95.   5.2 How to read the docs without `Info?'
  96.   5.3 How to print the docs?
  97.   5.4 Where can I find docs in PostScript?
  98.   5.5 Some docs are nowhere to be found...
  99.   5.6 What are these `foo.1' files?
  100.   5.7 What if the docs don't say enough?
  101. 6. When the Compiler (or `Make', or `Info', or ...) Crashes...
  102.   6.1 GCC says ``No DPMI''
  103.   6.2 Buggy DPMI host or junk in DJGPP.ENV can crash v2.x programs
  104.   6.3 GCC can crash during optimization
  105.   6.4 What does ``Fatal signal X'' mean?
  106.   6.5 What does ``Unknown filetype'' mean?
  107.   6.6 You can't use `QEMM' auto/off mode with DJGPP
  108.   6.7 Compiler hangs, but only when invoked from Make
  109.   6.8 Info doesn't like some files
  110.   6.9 My problem isn't mentioned above!
  111.   6.10 I can't keep up with the error messages
  112.   6.11 How to search DJGPP archives for similar problems
  113.   6.12 How to ask DJGPP gurus for help
  114. 7. Compiler and Linker Performance
  115.   7.1 Slow Compilation
  116.   7.2 Slow Linking
  117. 8. Compile-time and Link-time Problems
  118.   8.1 GCC can't find headers or libraries
  119.   8.2 GCC can't find C++ headers
  120.   8.3 GCC barfs on C++-style comments in C programs
  121.   8.4 How does GCC recognize the source language?
  122.   8.5 Problems with Objective C
  123.   8.6 Writing codes fragments which are specific to DJGPP
  124.   8.7 Unresolved externals when linking programs
  125.   8.8 How not to lose your head with all these libraries
  126.   8.9 DJGPP uses a one-pass linker
  127.   8.10 C++ functions still not found
  128.   8.11 Where is class Complex?
  129.   8.12 The linker complains about __pure_virtual function.
  130.   8.13 Unresolved djgpp_first_ctor
  131.   8.14 C++ programs yield large `.exe' file
  132.   8.15 Why are DJGPP `.exe' files so large?
  133.   8.16 Linker complains about `djgpp.lnk'
  134.   8.17 Linker fails to produce the EXE program under Novell
  135.   8.18 Linker fails for large object files or large libraries
  136.   8.19 Building Allegro library fails
  137. 9. Running Compiled Programs
  138.   9.1 My program crashes only in v2.0!
  139.   9.2 What is that gibberish printed when my program crashes?
  140.   9.3 Reading and writing binary files
  141.   9.4 Buffered screen I/O surprises
  142.   9.5 What do DJGPP programs need to run?
  143. 10. Writing and Running Graphics Programs
  144.   10.1 What GRX driver to use with your SVGA
  145.   10.2 Accessing the video memory
  146.   10.3 Graphics screen restoring under Windows
  147. 11. Floating Point Issues and FP Emulation
  148.   11.1 Floating code without 80387
  149.   11.2 Other FP emulators cannot be used with DJGPP
  150.   11.3 Floating-point emulation under OS/2
  151.   11.4 DJGPP doesn't support `-msoft-float'
  152.   11.5 Numeric exceptions---sometimes
  153.   11.6 Floating point inaccuracies when using emulator
  154.   11.7 Floating point exception in Objective-C programs
  155.   11.8 Floating point exception in libm functions
  156. 12. Debugging DJGPP Programs
  157.   12.1 How to run a DJGPP program under debugger
  158.   12.2 You need QEMM 7.53 or later
  159.   12.3 GDB won't debug unless it sees COFF output
  160.   12.4 Debuggers use the transfer buffer.
  161.   12.5 How to debug a graphics program
  162.   12.6 GDB finds only `.cc' source
  163.   12.7 Can GDB print class members?
  164.   12.8 GDB cannot list source that was #include'd
  165.   12.9 Debuggers choke on some programs ...
  166. 13. Profiling DJGPP Programs
  167.   13.1 How to profile a DJGPP program
  168.   13.2 Programs compiled with -pg crash when run
  169.   13.3 Gprof won't work unless it can find COFF executable
  170.   13.4 Where is Gprof docs?
  171.   13.5 Why is `__dpmi_int' so heavily used?
  172.   13.6 `gprof' doesn't produce output
  173. 14. Run-time Performance of DJGPP Programs
  174.   14.1 How efficient is DJGPP-generated code?
  175.   14.2 Comparing v2 with DJGPP v1.x
  176.   14.3 DJGPP programs on a Pentium
  177.   14.4 My program's I/O is so slow!
  178.   14.5 My ported program runs much slower!
  179. 15. Run-Time Memory Issues
  180.   15.1 How much virtual memory do you have?
  181.   15.2 It seems `malloc'/`free' don't affect virtual memory...
  182.   15.3 Failure to get more memory than is physically installed
  183.   15.4 Memory allocation fails before all memory is used
  184.   15.5 Memory allocation fails under Windows
  185.   15.6 Memory allocation peculiarities under Windows 9x
  186.   15.7 Memory allocation fails under EMM386 or HIMEM
  187.   15.8 How much memory do parent DJGPP programs leave for their child?
  188.   15.9 How much stack can I have in DJGPP programs?
  189. 16. Command-line Arguments Handling in DJGPP
  190.   16.1 Filename wildcards expansion under DJGPP
  191.   16.2 How to disable filename wildcards expansion
  192.   16.3 How to pass command-line arguments with quotes or <@>
  193.   16.4 How to pass command lines longer than 126 characters
  194.   16.5 What is the maximum length of command line under DJGPP
  195.   16.6 Why Make passes only 126 characters to programs?
  196. 17. Converting DOS Programs/Libraries to DJGPP
  197.   17.1 GCC/Gas won't accept valid assembly code ...
  198.   17.2 Double-check code produced by Gas
  199.   17.3 Converting Intel ASM syntax to AT&T syntax
  200.   17.4 Converted code GP Faults!
  201.   17.5 I want to use a `.obj' or `.lib' code with DJGPP
  202.   17.6 I *must* use my 16-bit code with DJGPP!!
  203.   17.7 What should I do with those ``near'' and ``far'' declarations?
  204.   17.8 How to convert _AX pseudo-registers?
  205. 18. Low-level DOS/BIOS and Hardware-oriented Programming
  206.   18.1 Got ``Unsupported INT 0xNN'' calling `int86'
  207.   18.2 How to use buffers with DOS/BIOS services
  208.   18.3 How to call software interrupt functions
  209.   18.4 How to move data between your program and conventional memory?
  210.   18.5 Conventional-memory addresses use only 20 bits
  211.   18.6 Fast access to memory-mapped devices or absolute addresses
  212.   18.7 Accessing absolute address above 1MB
  213.   18.8 How to make DOS/BIOS call your function
  214.   18.9 How to hook hardware interrupts
  215.   18.10 Should I use _go32_XXX or __dpmi_YYY functions?
  216.   18.11 Hardware interrupt hooking has its subtleties ...
  217.   18.12 How to read and write ports
  218.   18.13 Inline Assembly code with GCC
  219. 19. Legal Aspects
  220.   19.1 Legal (un)restrictions on DJGPP applications
  221.   19.2 Legal restrictions of DJGPP utilities and libraries
  222. 20. Getting Help
  223.   20.1 Don't post DJGPP-specific problems to GNU News groups
  224.   20.2 How to post to the mailing list
  225.   20.3 How to become a subscriber to the mailing list
  226.   20.4 How to unsubscribe from the mailing list
  227.   20.5 If you don't see any message from the list ...
  228.   20.6 Why do I get every message more than once?
  229.   20.7 DJGPP now has a news group!
  230. 21. Version 2 vs v1.x
  231.   21.1 New features in DJGPP v2
  232.   21.2 DJGPP environment in v2.x
  233. 22. Miscellany
  234.   22.1 How to change a DJGPP package?
  235.   22.2 Where to find sample DJGPP code or a package ported to DJGPP?
  236.   22.3 How to create symbolic links to programs
  237.   22.4 Where to find the DPMI specification?
  238.   22.5 The DJGPP Web site.
  239.   22.6 Where to upload your contributions to DJGPP
  240.   22.7 DJGPP as cross-compiler
  241.   22.8 GCC says ``garbage at end of number''
  242.   22.9 What should sizeof (struct xyzzy) return?
  243.   22.10 C++ doesn't pack structs!
  244.   22.11 How to avoid ``Abort, Retry, Fail'' messages
  245.   22.12 What is that `go32-v2.exe' program?
  246.   22.13 What is DXE?
  247.   22.14 Long Filenames Don't Work!
  248.   22.15 Make says ``missing separator''
  249.   22.16 What is in that `zoneinfo' directory?
  250.   22.17 Generating the FAQ in your favorite format
  251. 23. About this FAQ
  252. 24. Topic Index
  253. 25. Program Index
  254.  
  255. 1. If You Are In a Hurry
  256. ************************
  257.  
  258. **Q*: Do you really mean I have to read this looongish FAQ list to get my
  259. answers?*
  260.  
  261. **Q*: I have this problem which I absolutely MUST solve NOW!  What do I do?*
  262.  
  263. *A* : No, you don't need to read *all* of the FAQ unless you want to
  264. (although this is by all means recommended).  The questions in this document
  265. are listed, as much as possible, in the order they appear when one goes
  266. through getting DJGPP, installing it and using it.  To quickly find an answer
  267. to your question, first look at the Table of Contents, at the beginning of
  268. this document.  If that doesn't help, try the indices at the end of this
  269. manual.  You can either look up your question by program name in Chapter 25,
  270. or by topic name in Chapter 24.  If you don't find anything appropriate,
  271. search this FAQ for words which are pertinent to your problem.  For those in
  272. a *real* hurry, here are some pointers to the most important topics in this
  273. FAQ list:
  274.  
  275.    * How to ask experienced DJGPP users for help?
  276.  
  277.      Use the DJGPP News group or mailing list.  For most questions, you will
  278.      have your answer in a day or two.  See the details on how to ask the
  279.      gurus in Section 6.12.
  280.  
  281.    * What is the best configuration of my system for DJGPP?
  282.  
  283.      This depends on your hardware and software.  See system configuration
  284.      guidelines in Section 3.9.
  285.  
  286.    * Some files I need seem to be missing.  Where do I find them?
  287.  
  288.      Check out the list of required and optional packages in Section 4.5.
  289.  
  290.    * How do I subscribe to or unsubscribe from the DJGPP mailing list?
  291.  
  292.      See subscription instructions in Section 20.3.
  293.  
  294.    * How can I search News group/mailing list traffic for some info?
  295.  
  296.      This FAQ includes the description of DJGPP archive search server in
  297.      Section 6.11, set up by DJ Delorie <dj@delorie.com>, which you should
  298.      use whenever you have any questions or look for an information on a
  299.      DJGPP-related subject.
  300.  
  301. 2. What is DJGPP?
  302. *****************
  303.  
  304. **Q*: What is DJGPP?*
  305.  
  306. *A* :  DJGPP is a port of GNU C/C++ compiler and development tools to 32-bit,
  307. protected-mode environment on Intel 32-bit CPUs running MS-DOS and compatible
  308. operating systems, by DJ Delorie <dj@delorie.com> and friends.  Starting from
  309. v2.0, DJGPP programs do not need a separate extender program, only a DPMI
  310. server to run; DJGPP includes a free 32-bit DPMI server which allows for a
  311. 32-bit, 4 GByte flat address space and up to 256 MBytes of virtual memory, a
  312. compiler which produces 32-bit protected-mode code, and a suite of GNU
  313. development tools ported to MS-DOS.  These provide for a development
  314. environment which specifically favors porting Unix programs, but is also
  315. suitable for writing new code (for example, the DOS version of the well-known
  316. game `Quake' by id Software was compiled with DJGPP).  With a few exceptions
  317. (notably, some of the C++ class libraries), DJGPP is *free* which makes it
  318. deal for developing free and commercial software alike.
  319.  
  320. DJ Delorie <dj@delorie.com> is the developer and principal maintainer of
  321. DJGPP, but anyone is welcome and encouraged to contribute.
  322.  
  323. 3.  Hardware and Software Requirements
  324. **************************************
  325.  
  326.   This chapter describes what are the hardware and software which will allow
  327. you to use DJGPP.  Minimum, "reasonable" and optimal system configurations
  328. are listed.
  329.  
  330. 3.1 The minimum system requirements for using DJGPP
  331. ===================================================
  332.  
  333. **Q*: What are the minimum system requirements for using DJGPP?*
  334.  
  335. **Q*: Will DJGPP run on my brand-new Acme i986DX7/300 PC with a SCSI-III
  336. 10-Terabyte disk drive under MulticOS/42 v7.99 operating system?*
  337.  
  338. *A* :  DJGPP requires at least 386SX CPU and between 15 and 35 MB of free
  339. disk space (see more details on this below in Section 4.6), including space
  340. for the software installation and some swap space.  A minimum of 64K of
  341. system memory is enough for DJGPP to run with the CWSDPMI free DPMI host
  342. (most other DPMI hosts will require much more), but at least 2.5MB of free
  343. extended RAM is recommended for reasonably fast compilation of large source
  344. files (4MB for compiling large C++ programs); you might see painfully slow
  345. compiles for large sources if you don't have at least that much.  If your
  346. machine doesn't have a numeric co-processor, you will need to install an
  347. emulator to run floating-point code (DJGPP provides such an emulator) or link
  348. your applications with a special emulator library (also provided with DJGPP).
  349.  
  350. DJGPP will run under native DOS; any other operating system is OK if it
  351. includes a DPMI server.  Environments known to run DJGPP besides native DOS:
  352. Windows 3.1 & 3.11 DOS box, OS/2 (including Warp) DOS box, Windows 95/DOS 7,
  353. Windows NT (on Intel CPUs), Novell NWDOS 7 and Caldera's OpenDOS (but several
  354. people have found the DPMI services of NWDOS and OpendDOS incompatible with
  355. DJGPP, so they should probably be turned off and CWSDPMI used instead), and
  356. Linux DOSEmu environment.
  357.  
  358. 3.2 Does it really work under OS/2?
  359. ===================================
  360.  
  361. **Q*: You tell me it will work under OS/2, but I'm experiencing strange
  362. crashes after several compilations ...*
  363.  
  364. **Q*: DJGPP Make crashes when I run it on OS/2!*
  365.  
  366. *A* :  There was a bug in the DPMI server of the old OS/2 versions, which was
  367. triggered by spawning child processes (like GCC does when it invokes the
  368. various compiler passes).  Current versions of OS/2 don't have that bug, so
  369. DJGPP programs should run fine under OS/2.  If you can't make this happen,
  370. chances are that your setup is incorrect.  One system parameter that can
  371. cause problems with DJGPP (reportedly, Make crashes if it isn't set
  372. correctly) is `DPMI_DOS_API.'  Setting it to `ENABLED' instead of the default
  373. `AUTO' should solve the problem.  I'm also told that experimenting with the
  374. value of `DPMI_MEMORY_LIMIT' sometimes solves problems on OS/2.
  375.  
  376. If the above doesn't help, please post the details of the crashes you see to
  377. the DJGPP News group (see description of the DJGPP news group in Section
  378. 20.7) or mailing list (see how to post to the mailing list in Section 20.2),
  379. and somebody will help you.
  380.  
  381. 3.3 Will it work under Windows/NT?
  382. ==================================
  383.  
  384. **Q*: What about Windows NT?*
  385.  
  386. *A* :  Current Windows NT versions support DPMI programs in the DOS box, so
  387. DJGPP programs should in general run fine under NT (but see the list of
  388. possible problems below).  Therefore, beginning with DJGPP v2.0, the
  389. distribution doesn't include real-mode `gcc.exe' anymore, as it is not needed.
  390.  
  391. The DPMI server built into NT (and Windows 95) loses selectors with each
  392. child program that is invoked by a DJGPP program, so after about two thousand
  393. calls to functions from the `spawnXX' family you can see an error message
  394. like this:
  395.  
  396.        Load error: no DPMI selectors
  397.  
  398. This problem is likely to afflict only DJGPP ports of Unix shells (such as
  399. `bash'), since no other DJGPP program, not even `Make', is likely to call so
  400. many child programs before it exits.  The only known work-around is to exit
  401. the shell every now and then, because when all the available selectors are
  402. exhausted, the DOS box will crash.  I'm told that `Make' was seen crashing on
  403. long `Makefiles' on Windows 95, where the selectors are lost at even higher
  404. rate than on NT.  If you ever run a very long `Makefile' and see `Make' crash,
  405. just run `Make' again, and it will pick up where the crashed session has left
  406. off.
  407.  
  408. Note that the long filename API (the special LFN-aware functions of Int 21h)
  409. for DOS box is not supported by current versions of Win/NT, so you cannot
  410. have long filenames there from DJGPP programs.
  411.  
  412. You might have problems with using the SVGA modes of your video card under
  413. Win/NT.  That is because NT doesn't allow direct access to the SVGA
  414. registers, without which it is impossible to recognize the type of the SVGA
  415. and employ its capabilities.  For example, a user reported that GRX functions
  416. and the `MODETEST.EXE' program thought that only a standard VGA was
  417. installed, whereas he had an S3 card.  There is nothing you can do about this
  418. feature of Win/NT; that is the price you pay for the stability and protection
  419. you get under this OS (a runaway program that accesses hardware registers can
  420. wipe out your disk or wedge the entire system cold).  However, I'm told that
  421. Win/NT 4.0 supports "DirectX" which is a method of accessing screen, audio
  422. and other peripherals directly, so it's possible to use full GRX graphics
  423. capabilities there.
  424.  
  425. Programs that use the "nearptr" facility of DJGPP to access absolute memory
  426. addresses (e.g., for memory-mapped devices) won't work on NT, because its
  427. DPMI server silently ignores functions that set huge limits on selectors.
  428. Since the default algorithm which allocates memory from the DPMI server needs
  429. to set such huge limit in some rare cases, there's a small probability that a
  430. program will fail or crash even if it doesn't set selector limits in user
  431. code.  It is best to use the Unix-style `sbrk' algorithm in programs that run
  432. on Windows/NT.  See the library docs for `_crt0_startup_flags' where the
  433. `_CRT0_FLAG_UNIX_SBRK' bit is explained, for more info on this issue.  If you
  434. cannot switch to the Unixy `sbrk' (e.g., if you don't have access to its
  435. source), I'm told that sometimes such problems can be worked around if you
  436. run DJGPP programs in a full-screen session; your mileage may vary.
  437.  
  438. Some people report that NT servers cause much more problems than NT
  439. workstations of the same version and build.  It seems that these problems
  440. usually mean that NT installation was done incorrectly (maybe it is much
  441. harder to get it right with a server than with a workstation?).  If you have
  442. such problems, try to install a workstation, or re-install the server, and
  443. see if that helps.  And if you gain some insight as to why servers like DJGPP
  444. less than workstations, please tell what you've learned.
  445.  
  446. The Cygnus Win32 project is another (unrelated to DJGPP) port of GCC and
  447. development tools to WinNT and Win95 platforms, which specifically targets
  448. development of Windows programs.  It is available from the Cygnus archives,
  449. e.g. ftp://ftp.cygnus.com/pub/sac/win32/ or through the Web, at this URL:
  450.  
  451.      http://www.cygnus.com/misc/gnu-win32/
  452.  
  453. 3.4 Can it run under Linux?
  454. ===========================
  455.  
  456. **Q*: You say it works on Linux, but I seem to be unable to run the compiler
  457. from within Make...*
  458.  
  459. **Q*: I can run DJGPP on Linux, but Make crashes with SIGFPE on even the
  460. simplest Makefiles!*
  461.  
  462. *A* :  Versions of Linux which were released before 13 March 1996 need a
  463. patch to be able to reliably run nested DJGPP programs.  That patch was
  464. posted to the DJGPP mailing list and is available from the DJGPP mail
  465. archives, at this URL:
  466.  
  467.      http://www.delorie.com/djgpp/mail-archives/djgpp/1996/02/26/13:28:52
  468.  
  469. If you prefer to download that patch via ftp, you can find it on the DJGPP
  470. ftp server, e.g.
  471. ftp://ftp.delorie.com/pub/djgpp/contrib/dpmi-dosemu-djgpp.mail.
  472.  
  473. You might also need to edit the RAM section of the `dosemu.conf' file to make
  474. it comfortable for DJGPP.  I suggest setting `dpmi' and `xms' to 16MB and
  475. `ems' to 4MB.
  476.  
  477. Some users reported that `Make', and possibly other programs which use
  478. floating point computations, crash in DOSEmu environment on systems without
  479. an FPU, even if you set the 387 and EMU387 environment variables correctly
  480. (as explained in Setting up the FP emulator in Section 11.1, below).  The
  481. only known work-around is to not use floating point or to upgrade your
  482. machine hardware.  It is possible that newer versions of Linux might solve
  483. this problem too, so try upgrading your Linux software.
  484.  
  485. If your only problem is to run GNU Make, get the latest DJGPP port of Make,
  486. since ports of Make 3.75 or later can be configured to not issue FP
  487. instructions at all.
  488.  
  489. 3.5 Can I run it on a 286?
  490. ==========================
  491.  
  492. **Q*: Why can't I run DJGPP on my 286?  It has protected mode also...*
  493.  
  494. *A* :  True, but the protected mode isn't an issue here.  Gcc doesn't care
  495. much about memory protection, but it does care to run on a 32-bit processor,
  496. which the 286 isn't.  A 386 or better CPU really *is* required.
  497.  
  498. 3.6 MS-Windows applications and DJGPP
  499. =====================================
  500.  
  501. **Q*: Can I write MS-Windows applications with DJGPP?*
  502.  
  503. *A* : Currently, you can only run DJGPP programs under Windows as DOS apps
  504. (i.e. inside DOS Box).  If you need to write true Windows apps, you will have
  505. to use auxiliary tools.  One possibility is to use the RSX extender with EMX
  506. port of GCC and RSXWDK kit for Windows.  You can get RSX by anonymous ftp,
  507. e.g. ftp://ftp.uni-bielefeld.de/pub/systems/msdos/misc/.  People who tried
  508. using this package with DJGPP report that you must download and unzip the
  509. RSXWDK2 source archive, not only the binaries (otherwise you'll get General
  510. Protection Faults when you try to run DJGPP programs).  If you cannot reach
  511. the above site (some people say that it has closed its anonymous access), try
  512. looking on an alternative site, e.g.
  513. ftp://hermes.hrz.uni-bielefeld.de/pub/systems/msdos/misc/.  Other locations
  514. to look are RSXWDK on Cica mirrors, e.g.
  515. ftp://ftp.winsite.com/pub/pc/win3/programr/rsxwdk2s.zip, or RSXWDK on any of
  516. the TeX Archive Network sites, e.g.
  517. ftp://ftp.shsu.edu/tex-archive/systems/msdos/dpmigcc/.
  518.  
  519. Another problem with RSXWDK is that the Makefiles there are written for
  520. `ndmake', so they should be rewritten for GNU Make to work.  Some more
  521. hacking of Makefiles might be required due to the fact that they are set to
  522. work with EMX, and assume you unpacked everything into `/rsxwdk.'  You will
  523. also have to recompile the libraries as they were compiled with DJGPP v1.x,
  524. and hack the v2 startup file `crt0.s' along the same lines as the v1 version
  525. which comes with RSXWDK.  (`crt0.s' comes with the DJGPP source distribution,
  526. `djlsr201.zip'.)
  527.  
  528. Apart from RSXWDK, you will need a `windows.h' header file.  One place to
  529. find it is with the WINE distribution, e.g.
  530. ftp://ftp.cdrom.com/pub/FreeBSD/distfiles/ (you'll have to add -DWINELIB to
  531. CFLAGS when compiling).  However, be warned that this is a complete rewrite
  532. of the original, and might produce error messages when used to compile
  533. Windows apps.  I don't know about a better solution except using `windows.h'
  534. from a commercial compiler, which might get you into legal trouble.
  535.  
  536. You will also need a help compiler, e.g.
  537. ftp://ftp.aiai.ed.ac.uk/pub/packages/tex2rtf/rtfutils/hcp505.zip, or try at
  538. the Microsoft ftp site, e.g.
  539. ftp://ftp.microsoft.com/Softlib/MSFILES/HC305.EXE.  I'm told that, legally,
  540. you must already have purchased a help compiler from Microsoft to use either
  541. one of these.
  542.  
  543. A resource compiler is also required.  RSXNT (below) includes one such, but I
  544. didn't yet hear any success stories using it.  Anybody?
  545.  
  546. Note that, according RSXWDK's author, that package is meant for those who
  547. already have working debugged Windows applications and are simply looking to
  548. port them to 32-bit code.  Therefore, some crucial parts of a development
  549. environment (like a debugger) are missing there.  The author of RSX has
  550. recently discontinued his support of the package and switched to RSXNT
  551. project that targets Win32 (Win9x and WinNT) platforms (below).
  552.  
  553. As of this writing, nobody has reported any first-hand experience of using
  554. RSXWDK with DJGPP v2; the above is based on user reports under v1.x.  If you
  555. try RSXWDK with v2.x, please post a summary of your experience.
  556.  
  557. There is also a newer Windows development tool-chain by the author of RSXWDK
  558. called RSXNT.  This is targeted for Win32 platforms (Win95 and WinNT); it
  559. does have debugging tools included and has better support for DJGPP v2.x, but
  560. it needs to be registered (for a fee) if you want to develop commercial or
  561. shareware applications with it.  It can be found on the same sites as RSXWDK
  562. and comes with header files from Cygnus.  You can find the DJGPP-specific
  563. version of RSXNT on SimTel mirrors, e.g.
  564. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2tk/rsxntdj1.zip.  The sources
  565. of all the RSXNT utilities can be found in `rsxnt1.zip' archive on Cica
  566. mirrors, in the `win95/programr/' directory.  Note that currently, due to
  567. limitations of DJGPP, you cannot produce DLLs or programs that will run on
  568. Win32s platforms with RSXNT.
  569.  
  570. Another way to develop Windows applications is to use the Cygnus GCC/GPP
  571. port, at this URL:
  572.  
  573.      http://www.cygnus.com/gnu-win32/
  574.  
  575. You can also download it via anonymous ftp, e.g.
  576. ftp://ftp.cygnus.com/pub/sac/win32/.  This one's compatible with Win32 (Win95
  577. or WinNT, not Win32s), but requires you to comply with the GNU Copyleft
  578. system.  The Cygnus distribution includes development environments which run
  579. on WinNT and Linux, targeting WinNT and Win95 platforms.  Note that, as of
  580. this writing, the Cygnus port is still in early beta phase, and some nasty
  581. bugs are bound to be there.  Contact Steve Chamberlain <sac@rtl.cygnus.com>,
  582. for more details.
  583.  
  584. A better (but harder) way would be to volunteer to add Windows support to
  585. DJGPP.
  586.  
  587. 3.7 What you *should* buy ...
  588. =============================
  589.  
  590. **Q*: What is the optimal system configuration for running DJGPP?*
  591.  
  592. *A* :  Here is the description of your dream machine (at least for the next 6
  593. months :-):
  594.  
  595.    * Hardware:
  596.  
  597.         - the fastest CPU you can find (a 200 MHz Pentium-Pro as of this
  598.           writing);
  599.  
  600.         - at least 512KB second-level (off-chip) cache memory;
  601.  
  602.         - 128 MByte RAM;
  603.  
  604.         - motherboard built around fast 32-bit-wide bus (VLB or PCI);
  605.  
  606.         - SCSI-II hard disk with bus-mastering controller;
  607.  
  608.    * Software:
  609.  
  610.         - DOS, device drivers and TSRs all loaded HIGH, leaving only 5K DOS
  611.           footprint in lower (under 640K) memory;
  612.  
  613.         - 8 MByte RAM disk installed, `TMPDIR' environment variable points to
  614.           it (e.g., `set TMPDIR=e:', if E: is the RAM drive letter);
  615.  
  616.         - 8 MByte of disk cache, set to delayed-write operation;
  617.  
  618. 3.8 What most of us will *actually* buy ...
  619. ===========================================
  620.  
  621. **Q*: OK, I don't have this much money.  What is the *reasonable*
  622. configuration?*
  623.  
  624. *A* :  If you have the following machine, you should be able to stop worrying
  625. about memory and compilation performance:
  626.  
  627.    - CPU: 486DX2-66 with 256 KB off-chip cache;
  628.  
  629.    - RAM: 16 MByte;
  630.  
  631.    - Disk: 12 ms IDE with VLB controller, or SCSI;
  632.  
  633.    - 4 MByte RAM disk;
  634.  
  635.    - 3 MByte disk cache;
  636.  
  637. This will leave you with about 8 MBytes of free extended RAM.  Note that the
  638. RAM disk must be 4 MBytes to hold the output of the preprocessor for some
  639. exceedingly large source files (notably, some GCC source files).  If you
  640. don't have that much RAM to spare and still want to compile *very* large
  641. source files, either reduce the disk cache so you can give more to RAM disk,
  642. or point `TMPDIR' to your hard disk and make the disk cache larger, if you
  643. can.
  644.  
  645. 3.9 How to configure your system for DJGPP?
  646. ===========================================
  647.  
  648. **Q*: How do I configure my system to get optimal performance under DJGPP?*
  649.  
  650. *A* :  That depends on the amount of RAM you have installed in your machine.
  651. Below are some guidelines to help you.
  652.  
  653.   a. If you have 2 MBytes or less RAM installed:
  654.  
  655.         * Don't use *any* memory manager.
  656.  
  657.         * Use of `CWSDPMI' as your DPMI host is highly recommended.
  658.  
  659.         * Remove any TSR and device drivers you don't absolutely need (like
  660.           `SETVER.EXE', `HIMEM.SYS' etc.) from your `CONFIG.SYS' and
  661.           `AUTOEXEC.BAT.'
  662.  
  663.         * Do *not* install disk cache or RAM disk; point your `TMPDIR'
  664.           environment variable to a directory on your hard disk.  Put a
  665.           sufficiently large `BUFFERS=' statement into your `CONFIG.SYS' (I
  666.           recommend setting `BUFFERS=40,8') to make DOS file operations
  667.           faster.
  668.  
  669.         * If you use `CWSDPMI' as your DPMI host, get the `CWSPARAM' program
  670.           (from the `csdpmi3b.zip' archive) and set the "Minimum application
  671.           memory desired before 640K paging" parameter to 512K or larger.
  672.           Depending on how much memory you actually have, you might need to
  673.           further fine-tune this parameter.  This parameter defines the
  674.           lowest amount of extended memory CWSDPMI will use; if your system
  675.           doesn't have that much free extended RAM, CWSDPMI will use
  676.           conventional memory instead, where usually there should be around
  677.           600K of free RAM.
  678.  
  679.         * If you run under Windows, be sure to set the maximum amount of
  680.           extended memory on your PIF file for the DOS box to a reasonable
  681.           value.
  682.  
  683.      With this configuration, GCC will run out of free physical RAM and start
  684.      paging when compiling almost any C program and all C++ programs.  If you
  685.      are serious about DJGPP development, you need to buy more RAM *urgently*.
  686.  
  687.   b. If you have 2-4 MBytes of RAM installed:
  688.  
  689.         * Don't use *any* memory manager.
  690.  
  691.         * Remove any TSR and device driver you don't absolutely need (like
  692.           `SETVER.EXE', `HIMEM.SYS') from your `CONFIG.SYS' and
  693.           `AUTOEXEC.BAT.'
  694.  
  695.         * Get a disk cache which works from conventional memory and configure
  696.           it to 256K size at most, or don't use a cache at all.
  697.  
  698.         * Do *not* install a RAM disk; point your `TMPDIR' environment
  699.           variable to a directory on your hard disk.
  700.  
  701.         * If you run under Windows, be sure to set the maximum amount of
  702.           extended memory on your PIF file for the DOS box to a reasonable
  703.           value.
  704.  
  705.      With this configuration, GCC will still run out of free physical RAM and
  706.      start paging when compiling large C programs and most C++ programs.
  707.      Plan to buy more RAM as soon as you can.
  708.  
  709.   c. If you have 5-8 MBytes of RAM installed:
  710.  
  711.         * Use a memory manager such as EMM386 or QEMM386.  Try using the
  712.           FRAME=NONE parameter of the memory manager.  This will disable
  713.           Expanded Memory (EMS) services as far as most programs are
  714.           concerned; if you must use DJGPP together with any program which
  715.           needs EMS, try to configure that program to use Extended Memory
  716.           (XMS) instead.
  717.  
  718.         * Load DOS, device drivers and TSRs *HIGH*.
  719.  
  720.         * Give your disk cache 1 MByte of RAM.  Enable its delayed-write (aka
  721.           write-back) feature.
  722.  
  723.         * Do *not* install a RAM disk; point your `TMPDIR' environment
  724.           variable to a directory on your hard disk.
  725.  
  726.         * If, after configuring your system as above, you still have more
  727.           than 2.5 MBytes of free RAM left (4 MBytes, if you plan to program
  728.           in C++ a lot), enlarge the disk cache size.
  729.  
  730.         * If you run under Windows, be sure to set the maximum amount of
  731.           extended memory on your PIF file for the DOS box to a reasonable
  732.           value.
  733.  
  734.   d. If you have more than 8 MBytes of RAM:
  735.  
  736.         * Use a memory manager to load DOS, TSRs and device drivers *HIGH*.
  737.  
  738.         * Install at least a 2-MByte-large disk cache, configured to use the
  739.           delayed- write feature.  If you have plenty of RAM, you can give
  740.           your cache as much as 8 MBytes of memory.
  741.  
  742.         * If you have more than 5 MBytes left, install a RAM disk with a size
  743.           of at least 1.5 MBytes and point your `TMPDIR' environment variable
  744.           to it.  If your RAM disk is less than 4 MBytes, GCC might run out
  745.           of space there for *very* large source files (e.g., cccp.c file
  746.           from the GCC source distribution), but this shouldn't happen unless
  747.           the size of the source file you are compiling approaches 1 MByte.
  748.  
  749. Some people disable the delayed-write feature for safety reasons, to avoid
  750. losing files due to system crashes.  If you are worried about this, you can
  751. usually gain performance without sacrificing safety by enabling delayed-write
  752. together with an option that causes the cache to flush the write-behind data
  753. before the system returns to the DOS prompt.  For a `SmartDrv' disk cache,
  754. this is achieved by specifying `/N/F' switches instead of `/X'.
  755.  
  756. A tutorial is available on how to set up and get started with DJGPP, at this
  757. URL:
  758.  
  759.      http://remus.rutgers.edu/~avly/djgpp.html
  760.  
  761. 4. Where and What to Download?
  762. ******************************
  763.  
  764.   This chapter explains where and how can you get DJGPP, and recommends which
  765. parts of the archive you should download.
  766.  
  767. 4.1 Where can I get DJGPP?
  768. ==========================
  769.  
  770. **Q*: Where can I get DJGPP?*
  771.  
  772. *A* : Look on any SimTel.NET mirror in the pub/simtelnet/gnu/djgpp/
  773. subdirectory.
  774.  
  775. Lately, there has been considerable confusion caused by the fact that the
  776. repository which was long known by the name "SimTel" is no longer called
  777. that; its new name is "CCT".  The name SimTel has moved (along with its
  778. originator and long-time manager, Keith Petersen <w8sdz@Simtel.Net>) to
  779. another distribution network which uses almost the same ftp sites, but in
  780. different subdirectories.  The name SimTel is copyrighted by this new
  781. distribution network, and so CCT will have to discontinue its use of that
  782. name.  Experience shows that SimTel.NET (not CCT) is better managed and
  783. updates propagate there much faster, so I advise you to try using SimTel
  784. mirrors first, and fall back to CCT only if a SimTel site is unavailable to
  785. you.  In particular, DJGPP version 2.01 and later wasn't even uploaded to CCT
  786. sites.
  787.  
  788. This section lists the SimTel.NET mirrors; see below in Section 4.2, for the
  789. list of CCT sites.
  790.  
  791. The primary SimTel.NET site is:
  792.      ftp.simtel.net, directory /pub/simtelnet/gnu/djgpp
  793.  
  794.      (ftp.simtel.net is actually several ftp sites arranged in a rotating
  795.      pattern of IP addresses to help balance the load and to avoid access
  796.      problems due to network outages and simultaneous user limits.)
  797.  
  798. Here is a list of hosts by countries that offer mirror sites:
  799. Argentina
  800.      ftp.satlink.com, directory /pub/mirrors/simtelnet/gnu/djgpp
  801.  
  802. Newcastle, Australia:
  803.      ftp.iniaccess.net.au, directory /pub/simtelnet/gnu/djgpp
  804.  
  805. Australia:
  806.      ftp.tas.gov.au, directory /pub/simtelnet/gnu/djgpp
  807.  
  808. Australia:
  809.      sunsite.anu.edu.au, directory /pub/simtelnet/gnu/djgpp
  810.  
  811. Vienna, Austria:
  812.      ftp.univie.ac.at, directory /mirror/simtelnet/gnu/djgpp
  813.  
  814. Brussels, Belgium:
  815.      ftp.linkline.be, directory /mirror/simtelnet/gnu/djgpp
  816.  
  817. Aarshot, Belgium:
  818.      ftp.tornado.be, directory /pub/simtelnet/gnu/djgpp
  819.  
  820. Sao Paulo, Brazil:
  821.      ftp.unicamp.br, directory /pub/simtelnet/gnu/djgpp
  822.  
  823. Brazil:
  824.      ftp.iis.com.br, directory /pub/simtelnet/gnu/djgpp
  825.  
  826. Bulgaria:
  827.      ftp.eunet.bg, directory /pub/simtelnet/gnu/djgpp
  828.  
  829. Ottawa, Canada:
  830.      ftp.crc.doc.ca, directory /systems/ibmpc/simtelnet/gnu/djgpp
  831.  
  832. Vancouver, Canada:
  833.      ftp.direct.ca, directory /pub/simtelnet/gnu/djgpp
  834.  
  835. Chile:
  836.      sunsite.dcc.uchile.cl, directory /pub/Mirror/simtelnet/gnu/djgpp
  837.  
  838. Beijing, China:
  839.      ftp.pku.edu.cn, directory /pub/simtelnet/gnu/djgpp
  840.  
  841. Czech Republic:
  842.      ftp.eunet.cz, directory /pub/simtelnet/gnu/djgpp
  843.  
  844. Prague, Czech Republic:
  845.      pub.vse.cz, directory /pub/simtelnet/gnu/djgpp
  846.  
  847. Czech Republic:
  848.      ftp.zcu.cz, directory /pub/simtelnet/gnu/djgpp
  849.  
  850. Espoo, Finland:
  851.      ftp.funet.fi, directory /mirrors/ftp.simtel.net/pub/simtelnet/gnu/djgpp
  852.  
  853. Neuilly, France:
  854.      ftp.grolier.fr, directory /pub/simtelnet/gnu/djgpp
  855.  
  856. Paris, France:
  857.      ftp.ibp.fr, directory /pub/simtelnet/gnu/djgpp
  858.  
  859. Germany:
  860.      ftp.mpi-sb.mpg.de, directory /pub/simtelnet/gnu/djgpp
  861.  
  862. Bochum, Germany:
  863.      ftp.rz.ruhr-uni-bochum.de, directory /pub/simtelnet/gnu/djgpp
  864.  
  865. Chemnitz, Germany:
  866.      ftp.tu-chemnitz.de, directory /pub/simtelnet/gnu/djgpp
  867.  
  868. Heidelberg, Germany:
  869.      ftp.uni-heidelberg.de, directory /pub/simtelnet/gnu/djgpp
  870.  
  871. Magdeburg, Germany:
  872.      ftp.uni-magdeburg.de, directory /pub/simtelnet/gnu/djgpp
  873.  
  874. Paderborn, Germany:
  875.      ftp.uni-paderborn.de, directory /pub/simtelnet/gnu/djgpp
  876.  
  877. Trier, Germany:
  878.      ftp.uni-trier.de, directory /pub/pc/mirrors/simtelnet/gnu/djgpp
  879.  
  880. Wuerzburg, Germany:
  881.      ftp.rz.uni-wuerzburg.de, directory /pub/pc/simtelnet/gnu/djgpp
  882.  
  883. Athens, Greece:
  884.      ftp.ntua.gr, directory /pub/pc/simtelnet/gnu/djgpp
  885.  
  886. Hong Kong:
  887.      sunsite.ust.hk, directory /pub/simtelnet/gnu/djgpp
  888.  
  889. Hong Kong:
  890.      ftp.hkstar.com, directory /pub/simtelnet/gnu/djgpp
  891.  
  892. Hong Kong:
  893.      ftp.cs.cuhk.hk, directory /pub/simtelnet/gnu/djgpp
  894.  
  895. Ireland:
  896.      ftp.iol.ie, directory /pub/simtelnet/gnu/djgpp
  897.  
  898. Jerusalem, Israel:
  899.      ftp.huji.ac.il, directory /pub/simtelnet/gnu/djgpp
  900.  
  901. Naples, Italy:
  902.      ftp.unina.it, directory /pub/simtelnet/gnu/djgpp
  903.  
  904. Italy:
  905.      cis.utovrm.it, directory /simtelnet/gnu/djgpp
  906.  
  907. Italy:
  908.      ftp.flashnet.it, directory /pub/simtelnet/gnu/djgpp
  909.  
  910. Italy:
  911.      mcftp.mclink.it, directory /pub/simtelnet/gnu/djgpp
  912.  
  913. Saitama, Japan:
  914.      ftp.saitama-u.ac.jp, directory /pub/simtelnet/gnu/djgpp
  915.  
  916. Saitama, Japan:
  917.      ftp.riken.go.jp, directory /pub/simtelnet/gnu/djgpp
  918.  
  919. Japan:
  920.      ftp.iij.ad.jp, directory /pub/simtelnet/gnu/djgpp
  921.  
  922. Japan:
  923.      ftp.u-aizu.ac.jp, directory /pub/PC/simtelnet/gnu/djgpp
  924.  
  925. Japan:
  926.      ring.aist.go.jp, directory /pub/simtelnet/gnu/djgpp
  927.  
  928. Japan:
  929.      ring.asahi-net.or.jp, directory /pub/simtelnet/gnu/djgpp
  930.  
  931. Japan:
  932.      ftp.web.ad.jp, directory /pub/simtelnet/gnu/djgpp
  933.  
  934. Latvia:
  935.      ftp.lanet.lv, directory /pub/mirror/simtelnet/gnu/djgpp
  936.  
  937. Malaysia:
  938.      ftp.jaring.my, directory /pub/simtelnet/gnu/djgpp
  939.  
  940. Malaysia:
  941.      ftp.mimos.my, directory /pub/simtelnet/gnu/djgpp
  942.  
  943. Mexico:
  944.      ftp.gdl.iteso.mx, directory /pub/simtelnet/gnu/djgpp
  945.  
  946. Netherlands:
  947.      ftp.euro.net, directory /d5/simtelnet/gnu/djgpp/
  948.  
  949. Utrecht, Netherlands:
  950.      ftp.nic.surfnet.nl, directory
  951.      /mirror-archive/software/simtelnet/gnu/djgpp
  952.  
  953. Wellington, New Zealand:
  954.      ftp.vuw.ac.nz, directory /pub/simtelnet/gnu/djgpp
  955.  
  956. Bergen, Norway:
  957.      ftp.bitcon.no, directory /pub/simtelnet/gnu/djgpp
  958.  
  959. Krakow, Poland:
  960.      ftp.cyf-kr.edu.pl, directory /pub/mirror/Simtel.Net/gnu/djgpp
  961.  
  962. Poznan, Poland:
  963.      ftp.man.poznan.pl, directory /pub/simtelnet/gnu/djgpp
  964.  
  965. Warsaw, Poland:
  966.      ftp.icm.edu.pl, directory /pub/simtelnet/gnu/djgpp
  967.  
  968. Aveiro, Portugal:
  969.      ftp.ua.pt, directory /pub/simtelnet/gnu/djgpp
  970.  
  971. Portugal:
  972.      ftp.ip.pt, directory /pub/simtelnet/gnu/djgpp
  973.  
  974. Romania:
  975.      ftp.sorostm.ro, directory /pub/simtelnet/gnu/djgpp
  976.  
  977. Singapore:
  978.      ftp.nus.sg, directory /pub/simtelnet/gnu/djgpp
  979.  
  980. Slovakia:
  981.      ftp.uakom.sk, directory /pub/simtelnet/gnu/djgpp
  982.  
  983. Slovenia:
  984.      ftp.arnes.si, directory /software/simtelnet/gnu/djgpp
  985.  
  986. Johannesburg, South Africa:
  987.      ftp.is.co.za, directory /pub/simtelnet/gnu/djgpp
  988.  
  989. Stellenbosch, South Africa:
  990.      ftp.sun.ac.za, directory /pub/simtelnet/gnu/djgpp
  991.  
  992. Seoul, South Korea:
  993.      ftp.nuri.net, directory /pub/simtelnet/gnu/djgpp
  994.  
  995. South Korea:
  996.      ftp.sogang.ac.kr, directory /pub/simtelnet/gnu/djgpp
  997.  
  998. South Korea:
  999.      sunsite.snu.ac.kr, directory /pub/simtelnet/gnu/djgpp
  1000.  
  1001. Spain:
  1002.      ftp.rediris.es, directory /mirror/simtelnet/gnu/djgpp
  1003.  
  1004. Stockholm, Sweden:
  1005.      ftp.sunet.se, directory /pub/simtelnet/gnu/djgpp
  1006.  
  1007. Zurich, Switzerland:
  1008.      sunsite.cnlab-switch.ch, directory /mirror/simtelnet/gnu/djgpp
  1009.  
  1010. Chung-Li, Taiwan:
  1011.      ftp.ncu.edu.tw, directory /Packages/simtelnet/gnu/djgpp
  1012.  
  1013. Taipei, Taiwan:
  1014.      nctuccca.edu.tw, directory /PC/simtelnet/gnu/djgpp
  1015.  
  1016. Nonthaburi, Thailand:
  1017.      ftp.nectec.or.th, directory /pub/mirrors/simtelnet/gnu/djgpp
  1018.  
  1019. Edinburgh, UK:
  1020.      emwac.ed.ac.uk, directory /mirror/simtelnet/gnu/djgpp
  1021.  
  1022. Lancaster, UK:
  1023.      micros.hensa.ac.uk, directory /pub/simtelnet/gnu/djgpp
  1024.  
  1025. London, UK:
  1026.      sunsite.doc.ic.ac.uk, directory /packages/simtelnet/gnu/djgpp
  1027.  
  1028. London, UK:
  1029.      ftp.demon.co.uk, directory /pub/simtelnet/gnu/djgpp
  1030.  
  1031. Suffolk, UK:
  1032.      ftp.flexnet.net, directory /pub/simtelnet/gnu/djgpp
  1033.  
  1034. Concord, California, USA:
  1035.      ftp.cdrom.com, directory /pub/simtelnet/gnu/djgpp
  1036.  
  1037. California, USA:
  1038.      ftp.digital.com, directory /pub/simtelnet/gnu/djgpp/
  1039.  
  1040. California, USA:
  1041.      ftp.lib.sonoma.edu, directory /pub/simtelnet/gnu/djgpp/
  1042.  
  1043. Urbana, Illinois, USA:
  1044.      uarchive.cso.uiuc.edu, directory /pub/systems/pc/simtelnet/gnu/djgpp
  1045.  
  1046. Massachusets, USA
  1047.      ftp.bu.edu, directory /pub/mirrors/simtelnet/gnu/djgpp/
  1048.  
  1049. Rochester, Michigan, USA:
  1050.      OAK.Oakland.Edu, directory /pub/simtelnet/gnu/djgpp
  1051.  
  1052. New York, NY, USA:
  1053.      ftp.rge.com, directory /pub/systems/simtelnet/gnu/djgpp/
  1054.  
  1055. Oklahoma, USA:
  1056.      ftp.ou.edu, directory /pub/simtelnet/gnu/djgpp/
  1057.  
  1058. Corvallis, Oregon, USA:
  1059.      ftp.orst.edu, directory /pub/simtelnet/gnu/djgpp
  1060.  
  1061. Pennsylvania, USA:
  1062.      ftp.epix.net, directory /pub/simtelnet/gnu/djgpp
  1063.  
  1064. Utah, USA:
  1065.      ftp.cyber-naut.com, directory /pub/simtelnet/gnu/djgpp
  1066.  
  1067. Virginia, USA:
  1068.      mirrors.aol.com, directory /pub/simtelnet/gnu/djgpp/
  1069.  
  1070. 4.2 CCT sites
  1071. =============
  1072.  
  1073. **Q*: Where can I find the nearest CCT site?*
  1074.  
  1075. *A* :  Look up the site nearest to you in the list below:
  1076.  
  1077. Note that the copyright to the name "SimTel" is owned by Walnut Creek which
  1078. sponsors the SimTel.NET repository, so the CCT mirrors are in the process of
  1079. renaming their directories to `Coast'.  Therefore, if you don't find the
  1080. directories listed below, replace "SimTel" by "Coast" and try again.
  1081.  
  1082. The primary CCT site is in Detroit, Michigan, USA:
  1083.      ftp.coast.net, directory /Coast/vendors/djgpp/.
  1084.  
  1085. Here is a list of hosts by countries that offer mirror sites:
  1086. Canberra, Australia:
  1087.      archie.au, directory /micros/pc/SimTel/vendors/djgpp
  1088.  
  1089. Edmonton, AB, Canada:
  1090.      ftp.agt.net, directory /pub/SimTel/vendors/djgpp
  1091.  
  1092. Prague, Czech Republic:
  1093.      pub.vse.cz, directory /pub/simtel/vendors/djgpp
  1094.  
  1095. London, England:
  1096.      src.doc.ic.ac.uk, directory /pub/packages/simtel/vendors/djgpp
  1097.  
  1098. Liverpool, England:
  1099.      ftp.mersinet.co.uk, directory /pub/ibmpc/coast/vendors/djgpp
  1100.  
  1101. London, England:
  1102.      ftp.demon.co.uk, directory /pub/mirrors/simtel/vendors/djgpp
  1103.  
  1104. Chemnitz, Germany:
  1105.      ftp.tu-chemnitz.de, directory /pub/simtel/vendors/djgpp
  1106.  
  1107. Mainz, Germany:
  1108.      ftp.uni-mainz.de, directory /pub/pc/mirrors/simtel/vendors/djgpp
  1109.  
  1110. Tuebingen, Germany:
  1111.      ftp.uni-tuebingen.de, directory /pub/simtel/vendors/djgpp
  1112.  
  1113. Hong Kong:
  1114.      ftp.cs.cuhk.hk, directory /pub/simtel/vendors/djgpp
  1115.  
  1116. Hong Kong:
  1117.      sunsite.ust.hk, directory /pub/simtel/vendors/djgpp
  1118.  
  1119. Dublin, Ireland:
  1120.      ftp.hea.ie, directory /pub/simtel/vendors/djgpp
  1121.  
  1122. Haifa, Israel:
  1123.      ftp.technion.ac.il, directory /pub/unsupported/simtel/vendors/djgpp
  1124.  
  1125. Naples, Italy:
  1126.      ftp.unina.it, directory /pub/simtel/vendors/djgpp
  1127.  
  1128. Pisa, Italy:
  1129.      cnuce-arch.cnr.it, directory /pub/msdos/simtel/vendors/djgpp
  1130.  
  1131. Rome, Italy:
  1132.      ftp.flashnet.it, directory /mirror/simtel/vendors/djgpp
  1133.  
  1134. Rome, Italy:
  1135.      cis.utovrm.it, directory /SimTel/vendors/djgpp
  1136.  
  1137. Tokyo, Japan:
  1138.      ftp.crl.go.jp, directory /pub/pc/archives/simtel/vendors/djgpp
  1139.  
  1140. Tokyo, Japan:
  1141.      ftp.web.ad.jp, directory /pub/mirrors/Coast/vendors/djgpp
  1142.  
  1143. Tokyo, Japan:
  1144.      ring.aist.go.jp, directory /pub/coast/vendors/djgpp
  1145.  
  1146. Tokyo, Japan:
  1147.      ring.asahi-net.or.jp, directory /pub/coast/vendors/djgpp
  1148.  
  1149. Seoul, Korea:
  1150.      ftp.kornet.nm.kr, directory /pub/SimTel/vendors/djgpp
  1151.  
  1152. Seoul, Korea:
  1153.      ftp.nowcom.co.kr, directory /pub/SimTel/vendors/djgpp
  1154.  
  1155. Utrecht, Netherlands:
  1156.      ftp.nic.surfnet.nl, directory
  1157.      /mirror-archive/software/simtel-vendors/djgpp
  1158.  
  1159. Poznan, Poland:
  1160.      ftp.man.poznan.pl, directory /mirror/simtel/vendors/djgpp
  1161.  
  1162. Warsaw, Poland:
  1163.      ftp.icm.edu.pl, directory /pub/simtel/vendors/djgpp
  1164.  
  1165. Moscow, Russia:
  1166.      ftp.radio-msu.net, directory /mirror/Coast/vendors/djgpp
  1167.  
  1168. Singapore:
  1169.      ftp.singnet.com.sg, directory /pub/mirrors/SimTel/vendors/djgpp
  1170.  
  1171. Slovak Republic:
  1172.      ftp.uakom.sk, directory /pub/SimTel/vendors/djgpp
  1173.  
  1174. Taipei, Taiwan:
  1175.      nctuccca.edu.tw, directory /PC/simtel/vendors/djgpp
  1176.  
  1177. Bangkok, Thailand:
  1178.      ftp.bu.ac.th, directory /pub/SimTel/vendors/djgpp
  1179.  
  1180. Sunnyvale, CA, USA:
  1181.      ftp.drcdrom.com, directory /Coast/vendors/djgpp
  1182.  
  1183. Note that DJGPP was moved to the `SimTel/vendors/' directory on most CCT
  1184. mirrors about a year ago.  This is because CCT claims a compilation copyright
  1185. on its collection, to prevent people from copying the CD-ROMs which are
  1186. distributed by CCT.  The GNU GPL prohibits *any* restrictions, even on
  1187. compilations.  So, FSF asked for GNU and GNU-related files to be moved to a
  1188. separate directory to keep people from accidentally thinking that their
  1189. rights were being reduced.
  1190.  
  1191. 4.3 How do I download DJGPP?
  1192. ============================
  1193.  
  1194. **Q*: How do I download files from these sites?*
  1195.  
  1196. *A* :  FTP to the nearest site, log in as `anonymous', give your full e-mail
  1197. address as password, and chdir to the `djgpp' subdirectory (the exact path to
  1198. it might be different on different mirrors, check out the DJGPP archive path
  1199. in Section 4.1, for your nearest mirror.).  Then issue the `binary' command
  1200. and download files you need (see the list of required files in Section 4.5)
  1201. with the `get' or `mget' commands.
  1202.  
  1203. 4.4 What if I don't know what `FTP' is?
  1204. =======================================
  1205.  
  1206. **Q*: What is that `FTP' thing?  I only use `Mosaic' for Internet access.*
  1207.  
  1208. *A* :  OK, here are some URLs for your Web browser:
  1209.  
  1210.    - The main SimTel.NET site, at this URL:
  1211.  
  1212.           http://www.simtel.net/simtel.net/gnu/djgpp/
  1213.  
  1214.    - The main CCT site, at this URL:
  1215.  
  1216.           http://www.coast.net/Coast/vendors/djgpp/
  1217.  
  1218.    - The CCT mirror in Rochester, MI, at this URL:
  1219.  
  1220.           http://www.acs.oakland.edu/oak/SimTel/vendors/djgpp/
  1221.  
  1222.    - The CCT mirror in St. Louis, MO, at this URL:
  1223.  
  1224.           http://wuarchive.wustl.edu/systems/msdos/simtel/vendors/djgpp/
  1225.  
  1226. You can also convert any of the mirrors' addresses listed in the list of
  1227. SimTel.NET mirrors in Where to find, above to a valid URL by prepending
  1228. `ftp://' to it.  For example, here is the URL for FTP from the primary CCT
  1229. FTP site, e.g. ftp://ftp.coast.net/Coast/vendors/djgpp/.
  1230.  
  1231. Gopher users can access CCT files through a Gopher client,
  1232. gopher://gopher.oakland.edu.
  1233.  
  1234. For those of you who only have an e-mail connection to the Internet, CCT
  1235. files may be also obtained by e-mail from various ftp-mail servers or through
  1236. the BITNET/EARN file servers.  For details send a message to the CCT list
  1237. server <listserv@Coast.NET> with this command in the message body:
  1238.  
  1239.       get simtel-mailserver.info
  1240.  
  1241. 4.5 What Files to Download?
  1242. ===========================
  1243.  
  1244. **Q*: What's the minimum set of `.zip' files I need to download?*
  1245.  
  1246. *A* :  This depends on what you are planning to use DJGPP for.
  1247.  
  1248.    * To only run DJGPP-compiled programs, you MUST download all of these:
  1249.      (The version numbers of the packages below might not be up to date.  For
  1250.      the latest versions, check out the DJGPP Mini-FAQ posted weekly to the
  1251.      comp.os.msdos.djgpp news group.)
  1252.  
  1253.     `v2/readme.1st'
  1254.           This explains how to install DJGPP and get started with using it.
  1255.  
  1256.     `v2/faq210b.zip'
  1257.           The latest edition of this FAQ list.  Use it whenever you have
  1258.           problems installing and using DJGPP.
  1259.  
  1260.     `v2misc/csdpmi3b.zip'
  1261.           CWSDPMI, the DJGPP free DPMI server.  (If you can get DPMI services
  1262.           in your environment, like if you run under Windows, QDPMI, or OS/2,
  1263.           you don't need CWSDPMI, but I recommend downloading it nonetheless
  1264.           so you can try it in case you have trouble with other DPMI servers.)
  1265.  
  1266.     `v2misc/pmode11b.zip'
  1267.           This is an alternative DPMI server, PMODE/DJ.  Its memory footprint
  1268.           is smaller than CWSDPMI and it can be bundled with DJGPP programs
  1269.           to make a stand-alone executable that doesn't require a DPMI server
  1270.           to run.  PMODE/DJ doesn't support virtual memory and its
  1271.           implementation of the DPMI spec is a bit more restricted than that
  1272.           of CWSDPMI.
  1273.  
  1274.    * For developing C programs (no C++), you MUST download all of the above,
  1275.      plus the following:
  1276.  
  1277.     `v2gnu/bnu27b.zip'
  1278.           The GNU Binutils, including `as', the GNU assembler; `ld', the GNU
  1279.           linker; and their docs.
  1280.  
  1281.     `v2/djdev201.zip'
  1282.           C header files and libraries, library reference, minimal development
  1283.           environment, DJGPP-specific utilities and their documentation.
  1284.  
  1285.     `v2gnu/gcc2721b.zip'
  1286.           The GNU C Compiler binaries and docs (including the docs for the C++
  1287.           compiler).
  1288.  
  1289.     `v2gnu/txi390b.zip'
  1290.           Info, a stand-alone program to read GNU hypertext documentation
  1291.           files, and an environment to produce such files.  Without `info',
  1292.           you cannot read the C library reference and the docs included with
  1293.           the ported GNU software packages.
  1294.  
  1295.    * For developing C++ programs, you will need all of the above, plus the
  1296.      following:
  1297.  
  1298.     `v2gnu/gpp2721b.zip'
  1299.           The GNU C++ compiler binary (the docs are part of the gccNNNb.zip
  1300.           package, see above).
  1301.  
  1302.     `v2gnu/lgp271b.zip'
  1303.           The C++ header files, the GNU C++ class libraries, and their docs.
  1304.  
  1305.     `v2gnu/obc2721b.zip'
  1306.           If you want to develop Objective-C programs, you will need this
  1307.           file, which includes the Objective-C compiler and header files.
  1308.  
  1309.    * The following are some optional packages which you might want:
  1310.  
  1311.         - Debugging:
  1312.  
  1313.          `v2gnu/gdb416b.zip'
  1314.                GDB, the GNU Debugger and its docs.  (Note that the `djdev'
  1315.                distribution includes two simpler debuggers, `edebug' and
  1316.                `fsdb.'  The latter presents a user interface similar to that
  1317.                of Turbo Debugger.)
  1318.  
  1319.         - Additional development tools (consider getting at least the Make
  1320.           distribution):
  1321.  
  1322.          `v2gnu/mak375b.zip'
  1323.                GNU Make program with its docs.  You should install Make 3.75
  1324.                if you use DJGPP v2.01 (previous ports of Make have subtle
  1325.                incompatibilities with v2.01 tools).  The port of Make 3.75
  1326.                supports Unix-style shells (as well as DOS `COMMAND.COM' and
  1327.                its `4DOS/NDOS' replacements) and can be used to run Unix
  1328.                Makefiles if you install a Unix-style shell (e.g., `bash') and
  1329.                auxiliary utilities.  It also supports long filenames on
  1330.                Windows 9x and MSDOS pathnames with drive letters.
  1331.  
  1332.          `v2apps/rhide10b.zip'
  1333.                The RHIDE integrated development environment for DJGPP
  1334.                (similar to Borland's IDE), written by Robert Hoehne
  1335.                <Robert.Hoehne@Mathematik.TU-Chemnitz.DE>.  The latest version
  1336.                features an integrated debugger, based on GDB code; a
  1337.                stand-alone version of GDB with a Turbo Vision interface (but
  1338.                not all GDB features can be used); and support for user
  1339.                interface in languages other than English (using a port of GNU
  1340.                `Gettext' library).
  1341.  
  1342.          `v2/djlsr201.zip'
  1343.                The sources of the DJGPP C library and utilities written
  1344.                specifically for DJGPP.  If you can afford the disk space (it
  1345.                requires about 10MB), I recommend installing or at least
  1346.                downloading it, so you can easily fix possible library bugs.
  1347.  
  1348.          `v2gnu/bsh1147b.zip'
  1349.                Bash (`Borne-Again SHell'), the GNU shell, and its docs.  If
  1350.                you mostly work in Unix environment, you will feel right at
  1351.                home using `bash' as your interactive shell.  It is also great
  1352.                as a batch shell for running Unix-born shell scripts and
  1353.                Makefiles when these are too complex to convert them to MSDOS.
  1354.                If you install `bash', you should also install auxiliary
  1355.                utilities (Fileutils, Textutils, Sh-utils, Grep, Diffutils,
  1356.                Findutils, Sed and Gawk) as these are usually invoked from
  1357.                many shell scripts and Makefiles.
  1358.  
  1359.          `v2gnu/bsn124b.zip'
  1360.                Bison, a Yacc-like parser generator, and its docs.
  1361.  
  1362.          `v2gnu/dif271b.zip'
  1363.                GNU Diffutils (diff, cmp, diff3, sdiff), and their docs.  If
  1364.                you need to submit patches or changes to DJGPP or GNU sources,
  1365.                you will need the GNU `diff' program from this package.
  1366.  
  1367.          `v2gnu/emacs.README'
  1368.          `v2gnu/em1934*.zip'
  1369.                GNU Emacs, the most powerful, customizable, extensible
  1370.                programmer's editor known today.  The DJGPP port supports
  1371.                mouse, menu bar, pop-up menus, color syntax highlighting,
  1372.                reading Info documentation and compilation from within the
  1373.                editor, long filenames on Windows 9x, and much more.  Emacs
  1374.                can and should be used as an integrated development
  1375.                environment (another alternative is `RHIDE', see above).
  1376.                Please read the file `emacs.README' before you begin
  1377.                downloading the rest.
  1378.  
  1379.          `v2gnu/fil313b.zip'
  1380.                GNU Fileutils, including `ls', `rm', `cp', `mv', and others.
  1381.                Highlights of the latest port: `ls' supports colorization of
  1382.                files (like on Linux), `ln -s' knows about DJGPP-style
  1383.                "symlinks" (see symlink feature of DJGPP in Section 22.3,
  1384.                elsewhere in this document), `install -s' will strip
  1385.                executables on the fly, and all the utilities support long
  1386.                filenames on Windows 9x and numbered backups (even on plain
  1387.                DOS).  This package is a must if you want to run Unix shell
  1388.                scripts, as they use some of these utilities *a lot*.
  1389.  
  1390.          `v2gnu/flx252b.zip'
  1391.                Flex, a Lex-like lexical analyzer generator, and its docs.
  1392.  
  1393.          `v2gnu/grep20b.zip'
  1394.                GNU Grep package and its docs.  You need this if you use Emacs
  1395.                (which has commands that invoke Grep) or if you want to run
  1396.                Unix shells and Makefiles.
  1397.  
  1398.          `v2gnu/pat21b.zip'
  1399.                GNU Patch program and docs.  Required to apply patches to
  1400.                DJGPP sources.
  1401.  
  1402.          `v2gnu/sed118b.zip'
  1403.                GNU Sed (a batch editor) program and its docs.  Many ported
  1404.                packages require it during the build process on MSDOS.
  1405.  
  1406.          `v2gnu/shl112b.zip'
  1407.                GNU Sh-utils.  A must if you use the port of `bash' or want to
  1408.                run Unix Makefiles, but some utilities (such as `env' or
  1409.                `test') can also be very useful on their own right.
  1410.  
  1411.          `v2gnu/txt119b.zip'
  1412.                GNU Textutils.  Includes many useful programs, such as `sort',
  1413.                `wc', `cat', `join', `paste', `od', and `uniq'.  Unix shell
  1414.                scripts and Makefiles call some of these *a lot*, so you
  1415.                should install this package if you run them.
  1416.  
  1417.         - Developing text-mode and graphics GUI applications:
  1418.  
  1419.          `v2tk/grx20.zip'
  1420.                The DJGPP graphics library.
  1421.  
  1422.          `v2tk/bcc2grx.zip'
  1423.                The interface library to convert Borland graphics calls to GRX
  1424.                library calls.
  1425.  
  1426.          `v2tk/pdc22.zip'
  1427.                Public-domain Curses library.
  1428.  
  1429.      For description of additional files not mentioned here, get the file
  1430.      `00_index.txt'; it contains a full list of the distribution files and a
  1431.      short description of every file.
  1432.  
  1433. 4.6 How much disk space will I need?
  1434. ====================================
  1435.  
  1436. **Q*: Wow, that's a lot of files.  How much disk storage will I need?*
  1437.  
  1438. *A* :  The following lists the approximate disk space required for several
  1439. major configurations, and additional storage required for some optional
  1440. packages:
  1441.  
  1442.      Execution-only environment..................300 KBytes
  1443.      Developing C programs.......................13  MBytes
  1444.      Developing C++ programs.....................17  MBytes
  1445.      Developing Objective-C programs.............15  MBytes
  1446.      Additional storage for RHIDE................2.5 MBytes
  1447.      Additional storage for DJGPP sources........10  MBytes
  1448.      Additional storage for GDB..................1.1 MBytes
  1449.      Additional storage for Emacs................30  MBytes
  1450.      Additional storage for Flex.................280 KBytes
  1451.      Additional storage for Bison................310 KBytes
  1452.      Additional storage for Diffutils............560 KBytes
  1453.      Additional storage for Make.................520 KBytes
  1454.      Additional storage for Patch................120 KBytes
  1455.      Additional storage for Sed..................73  KBytes
  1456.      Additional storage for Graphics libraries...4   MBytes
  1457.  
  1458. Note that the above lists only approximate numbers.  In particular, the disk
  1459. cluster size can significantly change the actual disk space required by some
  1460. of the distributions (those with a large number of files).  The numbers above
  1461. are for disks up to 512MB which have 8KB-long clusters.
  1462.  
  1463. In addition to the space for installing the software, you will need some free
  1464. disk space for the swap file.  You should leave enough free disk space to
  1465. make the total virtual memory at least 20 MBytes; that will be enough for
  1466. most applications.  Invoke the `go32-v2.exe' program without arguments to see
  1467. how much DPMI memory and swap space DJGPP applications can use.  Depending on
  1468. your DPMI host, you might need to review its virtual memory settings in
  1469. addition to leaving free disk space; `CWSDPMI' requires only that enough free
  1470. disk space be available, but other DPMI hosts have special settings to
  1471. specify how much virtual memory they let their clients use, as explained
  1472. below in Section 15.1.
  1473.  
  1474. 4.7 Can I get away with less megabytes?
  1475. =======================================
  1476.  
  1477. **Q*: The above table means that I need more than 17 MBytes for C/C++
  1478. development environment; that's about 7 1.44MB diskettes to hold even the
  1479. compressed archive!!  Seems to me DJGPP is afflicted by the *fatware*
  1480. disease...*
  1481.  
  1482. **Q*: Pulling that many megabytes through the net from my overloaded
  1483. SimTel.NET mirror is almost impossible.  Can't you prepare a ZIP archive
  1484. which only includes stuff I can't do without?*
  1485.  
  1486. *A* : There are a number of shareware/freeware programs floating around which
  1487. allow formatting DOS diskettes to almost twice their usual capacity, so you
  1488. can use less floppies.  One such program is 2M, available from CCT mirrors as
  1489. 2mNN.zip, e.g. ftp://ftp.coast.net/Coast/msdos/diskutil/2m30.zip.
  1490.  
  1491. To make downloading DJGPP easier, download and compile the `BatchFTP'
  1492. program.  It allows you to submit a script of FTP commands and will
  1493. repeatedly try to login into the FTP site you specify until the script is
  1494. successfully completed.  It is smart enough to understand the messages which
  1495. the FTP server sends to you (like `login refused' etc.) and also is nice to
  1496. the remote server by sleeping for some time between login attempts.
  1497. `BatchFTP' is free software and can be found on many FTP sites, e.g.
  1498. ftp://oak.oakland.edu/pub/unix-c/networks/batchftp.tar.Z.
  1499.  
  1500. `BatchFTP' is a Unix program; those who access the net from their PC (not by
  1501. dialing into some Unix host with a shell account), can use a nice
  1502. FTP-automating utility called `AutoWinNet' (get the file autownNN.zip from
  1503. your nearest CCT mirror, e.g.
  1504. ftp://ftp.coast.net/Coast/win3/winsock/autown19.zip).
  1505.  
  1506. As for the minimal DJGPP installation, volunteers are welcome to prepare such
  1507. an archive and make it publicly available, in the same spirit as `EZ-GCC' did
  1508. for DJGPP v1.x.
  1509.  
  1510. 5. The DJGPP Documentation
  1511. **************************
  1512.  
  1513.   This chapter explains where to find and how to read DJGPP documentation, and
  1514. how to solve occasional problems with the docs system.
  1515.  
  1516. 5.1 Where are the documentation files?
  1517. ======================================
  1518.  
  1519. **Q*: I don't see any documentation files...*
  1520.  
  1521. *A* :  The documentation files are in the `info/' subdirectory of your main
  1522. DJGPP installation directory.  You will need a program to read these docs,
  1523. which are hypertext structured files.  You have several choices:
  1524.  
  1525.   a. Use the stand-alone `Info' reader.
  1526.  
  1527.      Get the file txi390b.zip, e.g.
  1528.      ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/txi390b.zip, which
  1529.      includes `INFO.EXE' and its docs.  Unzip it and run `Info.'  It will
  1530.      bring up a (hopefully) self-explanatory online help system.  Confused?
  1531.      Press `?' to see the list of all Info commands.  Still confused?  Press
  1532.      `h' to have `Info' take you on a guided tour through its commands and
  1533.      features.
  1534.  
  1535.   b. Use the `Info' command of your favorite editor.
  1536.  
  1537.      If you use Emacs, you already know about `Info.'  (What's that?  You
  1538.      don't?  Type `C-h <i>' and you will get the top-level menu of all the
  1539.      Info topics.)  RHIDE also has an integrated Info reader, which is the
  1540.      core of its help system.
  1541.  
  1542.  
  1543. 5.2 How to read the docs without `Info?'
  1544. ========================================
  1545.  
  1546. **Q*: I'm too old/lazy/busy to learn yet another browser, and I despise
  1547. uGNUsable programs like Emacs.  How in the world can I read the DJGPP docs??*
  1548.  
  1549. *A* :  Info files are almost plain ASCII files, so you should be able to view
  1550. them with your favorite text file browser or editor.  You will lose the
  1551. hypertext structure and you might have a hard time finding the next chapter
  1552. (hint: look up the name of the Next node at the beginning of this node, then
  1553. use the search commands of the browser, or the Grep program, to find that
  1554. name), but other than that you will see all the text.
  1555.  
  1556. Anthony Appleyard <A.APPLEYARD@fs2.mt.umist.ac.uk> has translated the Info
  1557. files for GNU C/C++ Compiler (`gcc.iNN') and GNU C Preprocessor (`cpp.iNN')
  1558. into ISO-8859 (aka plain ASCII), and Stephen Turnbull
  1559. <turnbull@shako.sk.tsukuba.ac.jp> has made them available on his anonymous
  1560. ftp and WWW server.  You can get them as `gcc.txt' and `preprocessor.txt' by
  1561. anonymous ftp, e.g. ftp://turnbull.sk.tsukuba.ac.jp/pub/djgpp/doc/; or get
  1562. them with your Web browser, at this URL:
  1563.  
  1564.      http://turnbull.sk.tsukuba.ac.jp/pub/djgpp/doc/
  1565.  
  1566. You can also produce pure ASCII files yourself, if you have their Texinfo
  1567. sources.  These are usually called `*.txi' or `*.tex' and should be included
  1568. with the source distribution of every package.  To produce an ASCII file
  1569. `foo.txt' from the Texinfo file `foo.txi', invoke the `Makeinfo' program like
  1570. this:
  1571.  
  1572.       makeinfo --no-split --no-headers --output foo.txt foo.txi
  1573.  
  1574. The `Makeinfo' program is part of the Texinfo distribution which is available
  1575. in txi390b.zip, e.g.
  1576. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/txi390b.zip.
  1577.  
  1578. If you prefer reading the docs through the Web, point your Web browser to the
  1579. docs page of the DJGPP Web site, at this URL:
  1580.  
  1581.      http://www.delorie.com/gnu/docs/
  1582.  
  1583. 5.3 How to print the docs?
  1584. ==========================
  1585.  
  1586. **Q*: I like my docs the old way: printed on paper, stacked near my
  1587. workplace.  How can I print the documentation files which come with DJGPP?*
  1588.  
  1589. *A* :  You will need to get and install a program called TeX or its
  1590. work-alike, like LaTeX or emTeX.  (They are NOT part of DJGPP.) Then run your
  1591. TeX work-alike on the docs' *source* files (called `*.txi' or `*.tex') which
  1592. you get with the source distribution of every package you download.  You will
  1593. get a `.dvi' file which you can print; or you can run a DVI-to-PostScript
  1594. converter such as `DVIPS' to produce a PostScript output.  `DVIPS' is a free
  1595. program; you can find it on SimTel.NET mirrors, e.g.
  1596. ftp://ftp.simtel.net/pub/simtelnet/msdos/postscrp/dvips558.zip.
  1597.  
  1598. DJGPP comes with a program called `TEXI2PS' which can convert *.txi files to
  1599. a crude PostScript; try it if you don't care much about the appearance of the
  1600. printed docs.
  1601.  
  1602. If TeX won't run, check that you have the file `texinfo.tex' which defines
  1603. the TeX macros specific to Texinfo files.  If you don't, get the latest GNU
  1604. or DJGPP Texinfo distribution which includes that file.
  1605.  
  1606. If you'd like to produce printed docs of the library reference, TeX might
  1607. complain that it cannot find a file named `libc2.tex'.  This file is
  1608. generated from all the `*.txh' files in the DJGPP source distribution
  1609. (`djlsr201.zip').  In order to build this file, you need to install
  1610. `djlsr201.zip', then go to the `src/libc' directory and type this from the DOS
  1611. command prompt:
  1612.  
  1613.        make -C ../mkdoc
  1614.        make doc
  1615.  
  1616. If the above command fails due to unresolved externals, you will need to edit
  1617. the file `makefile' in the `mkdoc' directory.  It has a line which calls `ld'
  1618. (the linker), where you should change `-lgcc -lc' into `-lgcc -lc -lgcc'.
  1619. Save `makefile' and try the above commands again.
  1620.  
  1621. Note that some documentation files (notably, those for GCC) will produce
  1622. voluminous print-outs.  You *have* been warned!
  1623.  
  1624. 5.4 Where can I find docs in PostScript?
  1625. ========================================
  1626.  
  1627. **Q*: I don't have all these fancy packages, and I don't have disk space to
  1628. install them in the first place.  Can't you guys just include with DJGPP a
  1629. set of ready-to-print PostScript files?*
  1630.  
  1631. *A* :  They are *very* large and would eat up too much storage (much more
  1632. than the fancy packages you don't want to install).  Most of the people read
  1633. the docs on-line and never print them anyway.  Sorry.
  1634.  
  1635. However, some *Good Samaritans* from all across the Net have taken time and
  1636. effort to produce the docs in PostScript format and made them available by
  1637. anonymous ftp.  The most full set of docs for the latest versions of GNU
  1638. software is available in plain ASCII, `zip' and `tar.gz' format by anonymous
  1639. ftp from phi.sinica.edu.tw, e.g. ftp://phi.sinica.edu.tw/pub/aspac/gnu/; they
  1640. are all for A4 paper.  Other places to look for PostScript versions of GNU
  1641. documentation are:
  1642.  
  1643. In European A4 format, e.g. ftp://liasun.epfl.ch/pub/gnu/ps-doc/.
  1644. In US letter format, e.g. ftp://primus.com/pub/gnu-ps/.
  1645. Many GNU manuals in `HTML' (hypertext) format, suitable for reading with your
  1646. Web browser, can be viewed at the DJGPP Web site, at this URL:
  1647.  
  1648.      http://www.delorie.com/gnu/docs/
  1649.  
  1650. DJGPP includes a utility called `TEXI2PS' which converts the Texinfo source
  1651. files to crude PostScript; try it.
  1652.  
  1653. 5.5 Some docs are nowhere to be found...
  1654. ========================================
  1655.  
  1656. **Q*: I looked in my `info/' subdirectory, but I can't find docs for some of
  1657. the utilities, like `Sed' or `Gprof.'*
  1658.  
  1659. *A* :  Download the source archive (`*s.zip') for that package and look
  1660. inside it, usually in the directory called `man' or `doc.'
  1661.  
  1662. 5.6 What are these `foo.1' files?
  1663. =================================
  1664.  
  1665. **Q*: Some docs files are called `foo.1' or `bar.man' or `baz.nroff', and
  1666. they seem to be written in some weird format which is very difficult to read.
  1667. How can I convert them to readable text files?*
  1668.  
  1669. *A* :  That weird format is the `troff' format which is used for writing Unix
  1670. manual pages.  The Unix command `man' converts them to formatted text files
  1671. which are usually displayed with a program like `more' or `less' (and here
  1672. `less' is considered to be more than `more' :-)).  The formatted file
  1673. includes bold and underlined letters produced by over-typing using Backspace
  1674. characters.  To format these files, you can choose one of these methods:
  1675.  
  1676.    * Get and install a DOS port of the `groff' package, or port it yourself
  1677.      (a very difficult task).  The latest `groff' distribution can be found
  1678.      on the GNU ftp archive, e.g. ftp://ftp.gnu.ai.mit.edu/pub/gnu/ or any of
  1679.      its mirrors.  A port of (an old version of) Groff to (an old version of)
  1680.      DJGPP can be downloaded from the DJGPP ftp server, e.g.
  1681.      ftp://ftp.delorie.com/pub/djgpp/contrib/groff.zip.
  1682.  
  1683.    * Get and install `CAWF', a DOS program which knows about most of the
  1684.      `troff' formatting commands.  `CAWF' can be found on one of the CCT
  1685.      mirrors, e.g. ftp://ftp.coast.net/Coast/msdos/textutil/cawf404.zip.
  1686.  
  1687.    * Write or port a `man' clone.  Source for one such clone was posted to
  1688.      the DJGPP news group, so you can get it there, at this URL:
  1689.  
  1690.           http://www.delorie.com/djgpp/mail-archives/djgpp/1995/06/19/12:57:43
  1691.  
  1692.      You can also download this port from the DJGPP ftp server, e.g.
  1693.      ftp://ftp.delorie.com/pub/djgpp/contrib/man-pc.zip.
  1694.  
  1695.    * Format the file on any Unix machine, and download the results to your PC.
  1696.      On Unix, typing `catman -p' will print the commands which are required
  1697.      to do this; you can then run those commands on your `*.1' `troff' source
  1698.      files.
  1699.  
  1700. No matter which of the above methods you choose, you will need some kind of
  1701. browser which understands how to show bold and underlined letters instead of
  1702. backspace-over-typed characters.  I suggest to download a DJGPP port of GNU
  1703. Less, e.g. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/lss321b.zip,
  1704. which uses colors to show bold and underlined letters.  Alternatively, you
  1705. can get the latest official GNU Less distribution, e.g.
  1706. ftp://ftp.gnu.ai.mit.edu/pub/gnu/less-321.tar.gz which can be compiled out of
  1707. the box with the Borland C compiler.  (Future versions of `Less' will also
  1708. compile with DJGPP.)
  1709.  
  1710. Another possibility for reading formatted man pages would be with an Emacs
  1711. editor, if you use one.  Emacs has a special command to read man pages, but
  1712. it requires a port or a clone of a Unix `man' command, described above.
  1713.  
  1714. Beginning with version 3.6, the stand-alone `Info' program can also read man
  1715. pages (it invokes a subsidiary program `man' to format them, then displays
  1716. its output; see the file `README.djgpp' in the DJGPP Texinfo distribution for
  1717. more details on how to set this up).  So if you have the DJGPP Texinfo
  1718. distribution, you can read man pages with `Info' already; if not, just
  1719. download Texinfo, e.g.
  1720. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/txi390b.zip.
  1721.  
  1722. Note that, for GNU packages, the man pages aren't always updated on a regular
  1723. basis.  If you need more up-to-date information, see the Info files.
  1724.  
  1725. 5.7 What if the docs don't say enough?
  1726. ======================================
  1727.  
  1728. **Q*: OK, I've got the docs and have read them, but I still can't figure out
  1729. some details.*
  1730.  
  1731. *A* :  Some ported packages include DJGPP-specific or MSDOS-specific `README'
  1732. files (named `README.dj', `README.dos' or some such), which explain
  1733. DOS-specific issues; you should read them before any serious use of the
  1734. package, or in case of any problems.  If this doesn't help, download the
  1735. sources and look there, or ask on the net--either the DJGPP News group or
  1736. appropriate GNU News groups.
  1737.  
  1738. 6. When the Compiler (or `Make', or `Info', or ...) Crashes...
  1739. **************************************************************
  1740.  
  1741.   This chapter explains how to deal with certain problems which may prevent
  1742. DJGPP programs from running on your machine.  The first 8 sections describe
  1743. specific problems; if yours isn't solved with these techniques, read the
  1744. description of the general debugging procedure in Section 6.9.
  1745.  
  1746. 6.1 GCC says "No DPMI"
  1747. ======================
  1748.  
  1749. **Q*: I'm trying to run `gcc', but all I get is a message saying "Load error:
  1750. no DPMI".  What am I doing wrong?*
  1751.  
  1752. *A* :  You don't have a DPMI server installed, and DJGPP v2 requires it to
  1753. run.  You can either use one of the commercial DPMI servers (e.g., run `gcc'
  1754. in a DOS box from Windows) or download and install CWSDPMI
  1755. (`v2misc/csdpmi3b.zip' from SimTel.NET mirrors) which is a free DPMI server
  1756. written for DJGPP.
  1757.  
  1758. 6.2 Buggy DPMI host or junk in DJGPP.ENV can crash v2.x programs
  1759. ================================================================
  1760.  
  1761. **Q*: When I try to run Info, it crashes immediately...*
  1762.  
  1763. **Q*: I cannot run v2 applications: they all hang or reboot my system, while
  1764. v1.x apps run OK.  Is this what v2 is all about--getting me out of the DJGPP
  1765. community?*
  1766.  
  1767. *A* : No, believe it or not, we don't want to oust you.  Your problems might
  1768. be caused by a buggy "DPMI" (see DOS Protected Mode Interface in Section
  1769. 22.4) host installed on your machine.  One DPMI host which is particularly
  1770. known to be a source of trouble is the one which comes with Novell NWDOS (and
  1771. also Caldera's OpenDOS, which is a derivative of NWDOS).  Please see if v2.0
  1772. programs run when you disable DPMI services of your usual configuration
  1773. (DJGPP programs will then use the CWSDPMI host supplied with DJGPP).  To turn
  1774. off the DPMI host built into Novell NWDOS and Caldera's OpenDOS, either
  1775. remove the `DPMI=TRUE' parameter from the EMM386 command line, or type `DPMI
  1776. OFF' from the DOS command prompt.
  1777.  
  1778. Another DPMI host which is known to cause problems in DJGPP is Quarterdeck's
  1779. QDPMI which comes with QEMM 7.5.  It was reported to cause `Info' and all
  1780. DJGPP debuggers to crash.  If you use QDPMI, upgrade to the version 7.53 or
  1781. later (patches for that version are available from the Quarterdeck's ftp
  1782. site), or disable QDPMI and use CWSDPMI.
  1783.  
  1784. Yet another cause of crashes in `Info' might be trailing whitespace in the
  1785. `DJGPP.ENV' file.  The telltale signs of this failure are a stack dump that
  1786. is bogus or doesn't start with your `main' function, or a series of SIGSEGV
  1787. that won't stop.  Actually, this is a bug in the DJGPP v2.0 startup code, so
  1788. any v2.0 program could crash in this way, but since the last section of stock
  1789. `DJGPP.ENV' belongs to `Info', it is the one which suffers most from this
  1790. bug.  Make sure your `DJGPP.ENV' doesn't have a `^Z' character at the end
  1791. (some DOS editors put it if you edit the file), and doesn't end with a blank
  1792. line.  Alternatively, upgrade to DJGPP v2.01 or later, where that bug is
  1793. fixed.
  1794.  
  1795. 6.3 GCC can crash during optimization
  1796. =====================================
  1797.  
  1798. **Q*: When I compile my program, the compiler crashes, but the problem seems
  1799. to go away if I compile without optimization.*
  1800.  
  1801. **Q*: The compiler prints "Virtual memory exhausted" and dies while compiling
  1802. some long functions with some optimization options, such as -funroll-loops or
  1803. -fforce-addr.*
  1804.  
  1805. *A* :  For some programs, this can be caused by an insufficient stack.  Some
  1806. source files make `cc1.exe' or `cc1plus.exe' need preposterously large
  1807. amounts of stack space, but only when you turn on optimizations.  (One user
  1808. reported that an innocent-looking C source file required 700KB of stack
  1809. before `cc1.exe' was able to compile it with optimizations!)  Try stubediting
  1810. the compiler to enlarge its stack, as described elsewhere in this FAQ, how to
  1811. enlarge the stack in Section 6.4, before you try any other remedies in this
  1812. section.
  1813.  
  1814. GCC 2.6.0 was known to crash when optimizing, especially when compiling C++
  1815. programs, but it can also happen for later versions, especially if your code
  1816. has some syntactic or semantic bug.  (This is usually a genuine GCC bug, not
  1817. something special to DJGPP.)  Upgrade to the latest version of GCC.  If that
  1818. doesn't help, then narrow the offending code fragment using the `#if 0 ...
  1819. #endif' paradigm.  If this fragment includes an error, correct it and try
  1820. again; if it is syntactically and semantically correct, then rewrite it as
  1821. equivalent, but syntactically different one.
  1822.  
  1823. If GCC reports that it has exhausted virtual memory, you should first see if
  1824. your swap space is large enough (run `go32-v2' with no arguments) and make
  1825. more free space on your disk if so.  Some users have reported that GCC seems
  1826. to run out of virtual memory if TMPDIR environment variable points to a RAM
  1827. disk which doesn't have enough free space.  Changing TMPDIR to point to a
  1828. hard disk would reportedly save the day in those cases.
  1829.  
  1830. An undocumented GCC switch can sometimes help you zero in on the code
  1831. fragment that causes GCC to crash.  If you add `-Q' to the GCC command line,
  1832. it will print the name of every function it compiles.  The function that
  1833. makes it crash is probably the one whose name is the last one printed, or the
  1834. one after that.
  1835.  
  1836. You can also try to disable the strength-reduction optimizations of GCC by
  1837. using the `-fno-strength-reduce' switch.  GCC has a known bug in that type of
  1838. optimization which goes back as far as version 2.5.8 and is only corrected in
  1839. GCC 2.7.2.1 or later; this bug raises its ugly head on rare occasions, but is
  1840. notoriously hard to hunt down when it does.  (The stock v2.0 distribution
  1841. should by default disable this kind of optimizations on the `lib/specs' file,
  1842. and v2.01 comes with GCC 2.7.2.1 where that bug is fixed.)
  1843.  
  1844. As an extreme measure, don't optimize at all, if that's the only way to make
  1845. your program compile.
  1846.  
  1847. Another reason for this could be some problem with your system hardware or
  1848. the BIOS (like if you set an incorrect number of wait states when accessing
  1849. memory).  To check, try running the same compilation on another machine, or
  1850. review your BIOS settings.
  1851.  
  1852. Yet another cause for such crashes can be connected with excess memory usage
  1853. that GCC needs when compiling certain programs, which makes some DPMI hosts
  1854. fail.  For details about this, see CWSDPMI allocation problems in Section
  1855. 6.4, in the next section.
  1856.  
  1857. 6.4 What does "Fatal signal X" mean?
  1858. ====================================
  1859.  
  1860. **Q*: I get "fatal signal 2" when I run GCC.*
  1861.  
  1862. **Q*: When I try compiling a program, GCC aborts saying "Installation
  1863. problem, cannot exec `as': No such file".  What does that mean?*
  1864.  
  1865. **Q*: GCC aborts with "Internal compiler error" when compiling a large C++
  1866. program.*
  1867.  
  1868. *A* : When GCC reports a "signal", it really means that an error occurred
  1869. trying to run one of the compiler passes.  The "signal" number is the DOS
  1870. error code, and 2 means "file not found" (dust off your DOS reference for
  1871. other error codes).  This (and the more explicit "cannot exec" message) means
  1872. GCC couldn't find some program it needs to run to compile your source.  Check
  1873. the `COMPILER_PATH' environment variable or what the `COMPILER_PATH' line in
  1874. the `DJGPP.ENV' file says, and make sure they point to the directory where
  1875. DJGPP programs reside.  Also check that the named directory has all the
  1876. required programs: `cpp.exe', `cc1.exe', `cc1plus.exe', `cxxfilt.exe',
  1877. `gasp.exe', `as.exe', `ld.exe', and (for Objective-C) `cc1obj.exe.'  A
  1878. typical case is when people fail to install the Binutils package, e.g.
  1879. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bnu27b.zip and GCC cannot
  1880. find `as.exe' (the assembler) and `ld.exe' (the linker).  You can use the
  1881. `-v' switch to GCC to see what programs it invokes and which one of them
  1882. causes the fatal error.
  1883.  
  1884. The "Internal compiler error" message usually means a genuine bug in GCC
  1885. (which should be reported to FSF), but it can also happen when GCC requests
  1886. additional chunk of memory, and the DPMI server fails to allocate it because
  1887. it exhausts available memory for its internal tables.  Release 1 of CWSDPMI
  1888. can fail like this if an application asks for a large number of small memory
  1889. chunks.  If you use release 1 of CWSDPMI, you can enlarge the maximum space
  1890. that CWSDPMI uses if you get a CWSDPMI heap-fix patch, e.g.
  1891. ftp://ftp.neosoft.com/pub/users/s/sandmann/csdpmi1heapfix.zip.  Beginning
  1892. with release 2, CWSDPMI defines a larger (6KB) default heap that is
  1893. configurable by CWSPARAM program to be anywhere between 3K and 40K bytes,
  1894. without recompiling CWSDPMI.  You should upgrade to the latest CWSDPMI if you
  1895. experience such problems.
  1896.  
  1897. You can also run `stubedit' on `cc1plus.exe' and enlarge its maximum stack
  1898. size to 512K bytes (some people report that they needed to enlarge both the
  1899. heap of CWSDPMI and the stack of the C++ compiler to make this problem go
  1900. away).  If you see such problems when compiling a C program, stubedit
  1901. `cc1.exe.'
  1902.  
  1903. For a program that you wrote, another work-around is to use an alternative
  1904. algorithm for `sbrk', by putting the following somewhere in your program:
  1905.  
  1906.        #include <crt0.h>
  1907.        int _crt0_startup_flags = _CRT0_FLAG_UNIX_SBRK;
  1908.  
  1909. Note that the Unix algorithm for `sbrk' might cause trouble in programs that
  1910. install hardware interrupts handlers.
  1911.  
  1912. 6.5 What does "Unknown filetype" mean?
  1913. ======================================
  1914.  
  1915. **Q*: I get error messages saying "Unknown filetype" from GCC.*
  1916.  
  1917. **Q*: Since a few days ago, whenever I try to run most of the DJGPP programs,
  1918. they print a message "C:\DJGPP\BIN\prog.exe: not COFF" and just terminate.
  1919. Help!!!*
  1920.  
  1921. *A* :  It might be that your DJGPP programs and/or `STUBIFY.EXE' are infected
  1922. by a virus.  (This is *not* a joke!  It did happen to a few of us and can
  1923. happen even to you.)  As the DOS stub prepended to the DJGPP programs is very
  1924. short, most viruses cannot attach themselves to it without overwriting the
  1925. beginning of the DJGPP COFF image which specifies vital information such as
  1926. location and length of various program sections, therefore triggering this
  1927. error from the code in the stub that loads the COFF image.
  1928.  
  1929. Another possible cause of the "Unknown filetype" message is that you mix a
  1930. v2.0 `gcc.exe' driver with `cc1plus.exe', `cc1.exe' or other programs from an
  1931. old v1.x distribution.
  1932.  
  1933. 6.6 You can't use `QEMM' auto/off mode with DJGPP
  1934. =================================================
  1935.  
  1936. **Q*: Why do I get error message from `CWSDPMI' if I keep QEMM in auto/off
  1937. mode and run DJGPP?*
  1938.  
  1939. *A* :  When QEMM is in auto/off mode and there isn't anything in the system
  1940. that is using any of QEMM's features, the CPU remains in real mode.
  1941. Normally, when CWSDPMI finds the CPU in real mode, it will try to use raw XMS
  1942. services to access the extended memory.  Unfortunately, when some program
  1943. requests XMS services, it will cause QEMM to turn on.  So if CWSDPMI tries to
  1944. switch into protected mode, QEMM will trap it and give a protection violation
  1945. warning.  To avoid this unfortunate event (which requires a system reboot to
  1946. fix), CWSDPMI first checks to see if enabling XMS caused the CPU to switch
  1947. into v86 mode (meaning QEMM just turned on).  If so, CWSDPMI gracefully exits
  1948. after telling you it can't work in this set-up, like this:
  1949.  
  1950.       "Error: Using XMS switched the CPU into V86 mode."
  1951.  
  1952. All you have to do to work around this is force QEMM to be ON whenever you
  1953. run DJGPP programs so that CWSDPMI will know how to work with it properly.
  1954. To do this, just turn QEMM on before running any DJGPP program, with this
  1955. command:
  1956.  
  1957.       c:\qemm\qemm on
  1958.  
  1959. (that assumes your QEMM directory is `c:\qemm').
  1960.  
  1961. 6.7 Compiler hangs, but only when invoked from Make
  1962. ===================================================
  1963.  
  1964. **Q*: My compiles run OK from the command line, but hang when I invoke the
  1965. compiler from Make.*
  1966.  
  1967. *A* :  Be sure you are invoking the correct Make program.  Borland Make was
  1968. reported to cause trouble when you invoke GCC with it (because Borland's
  1969. programs are 16-bit DPMI clients, and the DPMI 0.9 spec doesn't allow mixing
  1970. them with 32-bit DPMI clients such as DJGPP programs).  It might be that
  1971. another program called `make.exe' is found earlier on your `PATH' than the
  1972. Make which came with DJGPP.
  1973.  
  1974. If you use Make compiled under DJGPP v1.x, you will also experience all kinds
  1975. of trouble when invoking programs compiled under DJGPP v2.  That's because
  1976. v1.x programs cannot spawn v2 programs directly (the v1.x program sees that
  1977. the child is a DJGPP program and tries to call `go32' to run it, but v1's
  1978. `go32' cannot run v2 programs).  The result usually will be that the child
  1979. either crashes or silently exits.  If that's your problem, be sure to upgrade
  1980. your `Make' to the port distributed with v2. (Note that v2.x programs
  1981. generally know how to spawn both v1.x and v2.x programs.)  You can use
  1982. `go32-v2' to work around this limitation (see description of go32-v2 in
  1983. Section 22.12, below), but I suggest doing that only if you absolutely cannot
  1984. upgrade to v2's `Make.'
  1985.  
  1986. Some users report that v1.x programs might sometimes hang or reboot the
  1987. machine when invoked from v2.0 Make, if the Makefile calls the v1.x program
  1988. by a name longer than the 8+3 DOS filename restriction (that is usual for
  1989. Makefiles that come from Unix).  To work around, truncate the filename of
  1990. that program in the Makefile.
  1991.  
  1992. 6.8 Info doesn't like some files
  1993. ================================
  1994.  
  1995. **Q*: When I run the Info browser, it tells me it cannot find the node "Top".*
  1996.  
  1997. *A* :  Check your installation of info files.  The file `DJGPP.ENV' in the
  1998. root of your DJGPP installation mentions the variable `INFOPATH' which should
  1999. point to the directory where Info looks for its files.  It must find there a
  2000. file named `dir', the file you are trying to read, and other files with
  2001. `.iNN' or `.NN' extension, where `NN' is a number.
  2002.  
  2003. Assuming the above checks OK, and all the necessary info files are indeed
  2004. installed in those directories (did you remember to give that `-d' switch to
  2005. `PKUNZIP?'), it might be that some of the files were edited with a DOS-based
  2006. editor, which converted the <Newline> characters to the <CR>/<LF> pairs.
  2007. Some old DOS ports of Info don't like this, because this invalidates the tag
  2008. tables included with the files which Info uses to quickly find the various
  2009. nodes.
  2010.  
  2011. To solve the problem, upgrade to the latest versions of Info ported to DJGPP,
  2012. which don't have this problem (beginning with version 3.6).
  2013.  
  2014. If you cannot upgrade for some reason, run `DTOU.EXE' on the offending files;
  2015. it will strip the extra <CR> characters to make Info happy.  DTOU is in the
  2016. `bin/' subdirectory of your main DJGPP directory.
  2017.  
  2018. 6.9 My problem isn't mentioned above!
  2019. =====================================
  2020.  
  2021. **Q*: I've installed DJGPP just like explained in the `README.*' files, but
  2022. when I run gcc, my machine crashes/hangs/needs cold boot.*
  2023.  
  2024. **Q*: When I compile my program, gcc says "Segmentation violation" and prints
  2025. all kinds of funny numbers and registers.*
  2026.  
  2027. **Q*: I get errors I can't figure out when I try to compile something.*
  2028.  
  2029. *A* :  Add the `-v' switch to the GCC command line and run it again.  It will
  2030. print all the subprograms (compiler passes) it is running.  Then you can see
  2031. which subprogram caused the error, or where your machine crashes.  This might
  2032. give you a hint on what's wrong.
  2033.  
  2034. Another cause of such problems might be that your system is set up
  2035. inefficiently.  If GCC gets too few free RAM, it will run very slowly, and
  2036. you might think it crashed when in fact it didn't.  (This kind of problem
  2037. usually happens on memory-starved machines.)  Check out the system
  2038. configuration advice in Section 3.9, in this FAQ list and configure your
  2039. system accordingly.
  2040.  
  2041. 6.10 I can't keep up with the error messages
  2042. ============================================
  2043.  
  2044. **Q*: I want to read all the error messages that GCC throws at me, but there
  2045. are so many that I can't keep up.  How can I redirect them to a file?*
  2046.  
  2047. **Q*: When I add `-v' to the GCC command line, how can I put all the
  2048. voluminous output into a file, so I don't miss anything when reporting a
  2049. problem?*
  2050.  
  2051. **Q*: I have this nifty graphics program which bombs from time to time, but
  2052. the registers and traceback info are hidden by the graphics display.  How can
  2053. I see it?*
  2054.  
  2055. *A* :  Error messages are usually written to `stderr', and stock
  2056. `COMMAND.COM' cannot redirect it.  There are several alternatives to do that:
  2057.  
  2058.   a. You can use a shell smarter then `COMMAND.COM', such as `4DOS' or
  2059.      `bash', which knows how to redirect standard error stream to a file.
  2060.      4DOS is shareware and can be found on CCT mirrors, e.g.
  2061.      ftp://ftp.coast.net/Coast/msdos/4dos/, while `bash' is available from the
  2062.      DJGPP archives, e.g.
  2063.      ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh1147b.zip.
  2064.  
  2065.   b. You can also run your program under any one of the programs which save
  2066.      all screen output of programs they spawn in a file.  I suggest using a
  2067.      program called `SCRIPT', which is similar to its Unix namesake.  It has
  2068.      an advantage of saving everything which goes to screen *and* showing it
  2069.      on the screen at the same time.  You can find SCRIPT on CCT mirrors,
  2070.      e.g. ftp://ftp.coast.net/Coast/msdos/screen/script11.zip.
  2071.  
  2072.   c. Or you can use the `REDIR' program which comes with DJGPP.  It also
  2073.      redirects standard output and/or standard error to a file, but you don't
  2074.      get a chance to look at the output while the program runs.  Here's how
  2075.      to run GCC with `REDIR':
  2076.  
  2077.             redir -o gcc.log -eo gcc -v ...
  2078.  
  2079.      (put the rest of the GCC command line instead of the dots).  The
  2080.      messages printed by GCC will be written to the file `gcc.log'.
  2081.  
  2082.  
  2083. 6.11 How to search DJGPP archives for similar problems
  2084. ======================================================
  2085.  
  2086. **Q*: OK, I have all this voluminous output of `gcc -v', but I still have no
  2087. clue.*
  2088.  
  2089. *A* :  Your problem might be one which has already been posted and solved on
  2090. the DJGPP News group.  DJ Delorie <dj@delorie.com> has set up a searchable
  2091. News group archive on his Web server, at this URL:
  2092.  
  2093.      http://www.delorie.com/djgpp/mail-archives/
  2094.  
  2095. You can search the *entire* mailing list archives in just a few seconds.
  2096. DJ's archives are always up to date, as they receive and store all posted
  2097. messages automatically, but the index is updated every 24 hours, so the last
  2098. day might not be searchable yet.  To search the DJGPP archives, point your
  2099. Web browser to the above URL and specify a list of keywords pertinent to your
  2100. problem.  You will get a list of messages which include those keywords;
  2101. clicking on any of the messages will get the full text of that message.
  2102.  
  2103. 6.12 How to ask DJGPP gurus for help
  2104. ====================================
  2105.  
  2106. **Q*: I've searched the news group archives, but didn't find anything
  2107. helpful.  I am totally lost.  *Help!!!**
  2108.  
  2109. **Q*: I don't have time to download all these messages, not to mention
  2110. looking through them.  Can't you DJGPP gurus help me?  *Please??**
  2111.  
  2112. *A* :  DJGPP News group is famous for its outstanding user support.  To get a
  2113. fast and effective solution to your problem, you will have to supply the
  2114. relevant info about your system, and describe exactly how things went wrong
  2115. for you.  To gather this info, do the following:
  2116.  
  2117.    * At the DOS command prompt, type `set > environ.lst', then press <Enter>.
  2118.  
  2119.    * Invoke the `go32-v2' program (it's in your `bin/' subdirectory) and save
  2120.      its output.
  2121.  
  2122.    * Post to the comp.os.msdos.djgpp news group or write to the DJGPP mailing
  2123.      list <djgpp@delorie.com> and put into your message the description of
  2124.      your calamity, the contents of the file `ENVIRON.LST', the output of
  2125.      `go32-v2', the contents of your `AUTOEXEC.BAT' and `CONFIG.SYS', and
  2126.      what GCC printed during compilation with the `-v' switch (if your
  2127.      problem is that GCC won't work).
  2128.  
  2129.    * If your problem involves a program that crashes and prints a stack dump,
  2130.      please post that stack dump.  It's best to run `symify' on the stack
  2131.      dump, and post the output of `symify':
  2132.  
  2133.             symify -o dumpfile yourprog
  2134.  
  2135.      (See detailed description of symify in Section 9.2, for more details
  2136.      about `symify.')
  2137.  
  2138.    * Allow for 2-3 days (more on weekends) for all the reply messages to come
  2139.      in, then act according to what they recommend.
  2140.  
  2141. Be warned that you might get several dozen messages in reply to your request;
  2142. this is not meant to overflow your mailbox or sabotage your relationship with
  2143. your system manager, it's just the usual friendly response of fellow
  2144. DJGPP'ers to your lonely cry for help.  Some of the replies might suggest
  2145. what you already checked and reported in your original message, or even miss
  2146. the point altogether.  Be ready for this and don't flame us for trying to
  2147. help you as much as we can.
  2148.  
  2149. 7. Compiler and Linker Performance
  2150. **********************************
  2151.  
  2152.   This chapter deals with speed of compilation and linking under DJGPP, and how
  2153. they could be improved.
  2154.  
  2155.   If you already know whether the compiler or the linker is the slow part, go
  2156. to the appropriate section; if not, add `-v' to your GCC command line and run
  2157. it again.  With the `-v' switch, GCC will print all the programs it invokes,
  2158. and you will be able to tell which one is taking most of the time.
  2159.  
  2160. 7.1 Slow Compilation
  2161. ====================
  2162.  
  2163. **Q*: Why GCC is compiling sooo slooowww?*
  2164.  
  2165. *A* :  That depends on what you mean by "slow".  The following table gives
  2166. "normal" gcc compilation speed, in source lines per second, on a 486DX2-66:
  2167.  
  2168.                  |  Without optimization  |  With -O2
  2169.       -----------+------------------------+------------
  2170.       C++ source |        200             |   100
  2171.       -----------+------------------------+------------
  2172.       C   source |        430             |   250
  2173.  
  2174. (Btw, these numbers are about 20% faster than you will get on a 40MHz Sparc2
  2175. box.)  On machines faster or slower than 486DX2-66, scale these numbers
  2176. accordingly.  When comparing to this table, don't forget to count header
  2177. files your program `#include's' in the total line count.  And *don't* check
  2178. compilation speed on very short programs (like the classic `"Hello,
  2179. world!"'), because the overhead of loading the multiple passes of the
  2180. compiler will completely hide the compiler performance.
  2181.  
  2182. If your results are close to these (deviations of a few percent are
  2183. considered "close" here), then that's as fast as you can get with GCC.  If
  2184. they are *significantly* lower, you may indeed have a problem; read on.
  2185.  
  2186. First, check to see if GCC pages to disk when it compiles.  This is
  2187. manifested by a heavy disk traffic which won't go away even if you have a
  2188. large write-back disk cache installed.  To be sure, disable the virtual
  2189. memory services for your DPMI host (for `CWSDPMI', use the `CWSDPR0' as your
  2190. DPMI host, or use the `CWSPARAM' program to point the swap file to a
  2191. non-existent drive), or use `PMODE/DJ' as the DPMI host, then run the
  2192. compilation again; if the compiler aborts with an error message saying there
  2193. isn't enough memory, then it *was* paging in your original environment.
  2194.  
  2195. If paging does happen, you need to free more extended memory.  If you have a
  2196. RAM disk, make it smaller, or don't use it at all (it only makes compiles run
  2197. about 10% faster), or make your disk cache smaller (but don't discard the
  2198. disk cache altogether); if you have other programs which use extended RAM,
  2199. make them use less of it.  Failing all of the above, buy more RAM (see the
  2200. description of reasonable configuration in Section 3.8).  Also see
  2201. recommendations for optimal software configuration in Section 3.9.
  2202.  
  2203. If GCC doesn't page, check the settings of your disk cache.  If you don't use
  2204. a cache, install one--this can slash your compilation times by as much as
  2205. 30%, more so when compiling a large number of small files.  If you already
  2206. have a cache, enable its delayed-write (aka write-back, aka staggered-write)
  2207. operation.  Some people disable the delayed-write feature for safety reasons,
  2208. to avoid losing files due to system crashes.  If you are worried about this,
  2209. you can usually gain performance without sacrificing safety by enabling
  2210. delayed-write together with an option that causes the cache to flush the
  2211. write-behind data before the system returns to the DOS prompt.  (For
  2212. `SmartDrv' disk cache, this is achieved by specifying `/N/F' switches instead
  2213. of `/X'.)  GCC usually gains a lot when you set up your cache in such a way,
  2214. because each compiler pass (pre-processor, compiler, assembler) must write
  2215. temporary files that are used by the following passes.
  2216.  
  2217. If you had some of the beta releases of v2.0 installed during the
  2218. beta-testing period, be sure to upgrade your `CWSDPMI' to the latest version.
  2219. The memory allocation scheme has been changed halfway through the
  2220. beta-testing, which made old versions of `CWSDPMI' *awfully* slow when used
  2221. with programs linked against the new versions of the library.
  2222.  
  2223. It is also worthwhile to check the settings of your system BIOS.  In
  2224. particular, the following items should be checked against your motherboard
  2225. vendor recommendations:
  2226.  
  2227.      Internal and external CPU cache....set to Enable
  2228.      CPU cache scheme...................set to Write-back, if possible
  2229.      DRAM and SRAM wait states..........vendor-recommended optimal values
  2230.  
  2231. Incorrect or suboptimal settings of the above items can explain as much as
  2232. 30% performance degradation on 486 machines, and as much as 500% (!) if you
  2233. have a Pentium CPU.
  2234.  
  2235. DJ Delorie <dj@delorie.com> reports that his well-tuned 166 MHz Pentium
  2236. system with 32 MBytes of RAM and 4 MBytes of RAM disk compiles the entire GCC
  2237. source in under 10 minutes (this takes about 45 minutes on a 40MHz Sparc2).
  2238.  
  2239. 7.2 Slow Linking
  2240. ================
  2241.  
  2242. **Q*: The compiler finishes in a few seconds, but then the linker grinds away
  2243. for more than a minute, even on a very short program...*
  2244.  
  2245. *A* :  Try linking the trivial `"Hello, world!"' program; it should take no
  2246. more than 7-10 seconds on a 486, 3-5 seconds on a Pentium.  If you see much
  2247. slower linking on your system, then the following advice might help you.
  2248.  
  2249. A few users have reported that they got much faster linking after they've
  2250. stub-edited `ld.exe' to change the transfer buffer size to 64KB.  This
  2251. speedup effect is usually seen when DJGPP is installed on a networked drive,
  2252. or on a compressed disk; when DJGPP is installed on a local disk drive,
  2253. linking speed is not affected by the size of transfer buffer.
  2254.  
  2255. If you use a disk cache, make sure you enable its write-back (aka
  2256. delayed-write) operation.  Some people disable the delayed-write feature for
  2257. safety reasons, to avoid losing files due to system crashes.  If you are
  2258. worried about this, you can usually gain performance without sacrificing
  2259. safety by enabling delayed-write together with an option that causes the
  2260. cache to flush the write-behind data before the system returns to the DOS
  2261. prompt.  For `SmartDrv' disk cache, this is achieved by specifying `/N/F'
  2262. switches instead of `/X'.
  2263.  
  2264. For very large (several MBytes) executables which are built from a large
  2265. number of small source files, the link (as opposed to the compilation) stage
  2266. might be the one which needs more RAM than you have free, and thus be the
  2267. bottleneck of the time it takes to build your program.  Check that the size
  2268. of the executable isn't larger than the amount of your free RAM.  If it is,
  2269. then it might make sense to use a smaller (or even no) disk cache, and allow
  2270. the linker as much physical RAM as it needs.  Make sure that the linker
  2271. wasn't stub-edited to make its transfer buffer too small.
  2272.  
  2273. Another reason for slow linking might be that the `DJGPP.ENV' file by default
  2274. sets `TMPDIR' to a `tmp/' subdirectory of the main DJGPP installation
  2275. directory; if DJGPP is installed on a networked drive, this means all your
  2276. temporary files go back and forth through the network (and networked disks
  2277. are usually not cached on your PC).  In such cases, setting `TMPDIR' to a
  2278. directory on your local drive, or to a RAM disk, would probably make linking
  2279. faster.
  2280.  
  2281. 8. Compile-time and Link-time Problems
  2282. **************************************
  2283.  
  2284.   Being of a Unix origin, GCC has a somewhat different flavor of command-line
  2285. syntax and its peculiar compilation and link algorithms.  It also has a
  2286. plethora of optional switches, some of them obscure or semi-documented.
  2287. These are known to confuse users, especially those who had previous
  2288. experience with DOS-based C compilers.
  2289.  
  2290.   This chapter explains how to solve some of those problems which tend to
  2291. appear when compiling and linking your programs.
  2292.  
  2293. 8.1 GCC can't find headers or libraries
  2294. =======================================
  2295.  
  2296. **Q*: When I run the compiler it says it couldn't find header files and/or
  2297. libraries.  But the headers and libraries are all there, so why won't it find
  2298. them?*
  2299.  
  2300. **Q*: When I link my programs, ld.exe complains that it cannot open crt0.o,
  2301. although that file exists in the lib subdirectory...*
  2302.  
  2303. *A* :  In order for the compiler to find its include files, libraries and
  2304. other stuff it can't do without, you should have the following variable set
  2305. in your environment:
  2306.  
  2307.       set DJGPP=c:/djgpp/djgpp.env
  2308.  
  2309. and it should point to the correct path of the file `DJGPP.ENV' on your
  2310. system (the file itself comes with the file djdev201.zip, e.g.
  2311. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2/djdev201.zip in the DJGPP
  2312. distribution).  In the above example it is assumed to be in the `C:/DJGPP'
  2313. directory, but you should set it as appropriate for your installation.
  2314.  
  2315. Sometimes, people make errors in their `AUTOEXEC.BAT' that cause the DJGPP
  2316. variable to be defined incorrectly, or not defined at all (some of the more
  2317. common errors are listed below).  To check what is the actual setting, type
  2318. from the DOS prompt:
  2319.  
  2320.       set > env.lst
  2321.  
  2322. then examine the contents of the file `env.lst'.  You should see there a line
  2323. like this:
  2324.  
  2325.       DJGPP=c:/djgpp/djgpp.env
  2326.  
  2327. If a line such as this isn't there, you should investigate the cause for this
  2328. (see below for some of the possibilities).
  2329.  
  2330. Many problems with setting DJGPP happen when people put excess blanks around
  2331. the `=' character, which has the effect of defining "DJGPP " (with the blank)
  2332. which is not the same as "DJGPP" (without blanks).  You should make sure
  2333. there are no such excess blanks, or DJGPP won't find its files.
  2334.  
  2335. Another possible cause of DJGPP variable not being set is that you invoke
  2336. another batch file from your `AUTOEXEC.BAT' before the line that sets DJGPP.
  2337. Make sure such batch files are invoked with the `CALL' statement, because
  2338. otherwise the subsidiary batch file will never return to process the rest of
  2339. `AUTOEXEC.BAT' (that's a "feature" of DOS batch file processing).
  2340.  
  2341. The code that processes `DJGPP.ENV' assumes that this file resides in the
  2342. main DJGPP installation directory.  If that assumption is wrong, the compiler
  2343. (and some other DJGPP programs) might fail to find some of the files or
  2344. auxiliary programs they need.  *Do NOT move DJGPP.ENV to any other directory!*
  2345.  
  2346. Note that if you run DJGPP under Win95, WinNT or any other environment that
  2347. supports long filenames (e.g., if DJGPP is installed on a networked drive
  2348. whose network redirector supports long filenames), you *cannot* use long
  2349. names of the directories in the pathname of `DJGPP.ENV' when you set the
  2350. above variable in the environment; you should use their 8+3 aliases instead.
  2351. First, some of these systems (such as WinNT) do not even support the LFN API
  2352. for DOS programs.  But even if LFN API *is* supported, e.g. on Win95, DJGPP
  2353. won't know that it should support LFN until *after* it read `DJGPP.ENV'--it's
  2354. a chicken-and-egg problem.  For example, the following setting *won't work*
  2355. because `Development' is longer than 8 characters:
  2356.  
  2357.       set DJGPP=c:/Programs/Development/Djgpp/djgpp.env
  2358.  
  2359. If the DJGPP variable is set correctly, then check the following possible
  2360. causes of this misbehavior:
  2361.  
  2362.    * You have edited the file `DJGPP.ENV' in a way that invalidated some of
  2363.      the settings there; try restoring the original file from the
  2364.      distribution to see if that fixes your problems.  Be sure you are
  2365.      familiar with the syntax of `DJGPP.ENV' before you edit it.  The DJGPP
  2366.      server has a page with a description of the `DJGPP.ENV' syntax, at this
  2367.      URL:
  2368.  
  2369.           http://www.delorie.com/djgpp/doc/kb/kb_7.html#SEC7
  2370.  
  2371.      The syntax of `DJGPP.ENV' is also described in the DJGPP Knowledge Base,
  2372.      See  in (kb.inf)DJGPP.ENV, which comes with the `djdev' distribution.
  2373.  
  2374.    * Some older versions of Novell Netware cause the linker to fail if the
  2375.      libraries or the startup file `crt0.o' reside on a networked drive.
  2376.      This is due to a peculiarity of Novell that happens to fail the library
  2377.      function `stat' in some cases.  The exact reason of the failure has been
  2378.      identified, and the library which comes with DJGPP v2.01 includes a
  2379.      version of `stat' that works around that problem, so the linker from
  2380.      v2.01 is free of this bug, and upgrading will solve this.  Another
  2381.      solution would be to upgrade your Novell software; version 4.x is
  2382.      reportedly free of this problem, even if you use DJGPP v2.0.
  2383.  
  2384.    * You renamed the `gcc.exe' driver to some other name.  In this case, you
  2385.      should edit the file `DJGPP.ENV' to add a section named after the new
  2386.      name of GCC, which is an exact duplicate of the section called `[gcc].'
  2387.      DJGPP start-up code uses this file to find environment variables which
  2388.      it should put into the environment before the `main' function is called,
  2389.      but it searches for the relevant variables using the actual name of the
  2390.      program, so when you rename the executable, it can't find its section
  2391.      and doesn't put the necessary variables into the environment.
  2392.  
  2393.    * Your `FILES=' setting in `CONFIG.SYS' is insufficient, so GCC runs out
  2394.      of available handles.
  2395.  
  2396.      You should have at least `FILE=15' in your `CONFIG.SYS.'
  2397.  
  2398.    * Your DJGPP directory is on a networked drive, and the network redirector
  2399.      doesn't have enough available handles in its configuration.
  2400.  
  2401.      Presumably, there should be a parameter in some configuration file or a
  2402.      command-line argument to one of the network drivers which sets the number
  2403.      of files that can be open simultaneously on a networked drive; you should
  2404.      set it to be at least 15.
  2405.  
  2406.    * You passed the `-B' switch to GCC.  This overrides the default location
  2407.      of `crt0.o' and if you follow `-B' with a directory other than that
  2408.      where `crt0.o' resides, the linker won't find it.
  2409.  
  2410.      You should not need to use the `-B' or `-L' switches at all if your
  2411.      installation is correct and the `DJGPP' variable points to the main
  2412.      installation directory, because GCC should be able to figure out all the
  2413.      linker switches itself.  If linking fails without explicit `-L' or `-B',
  2414.      check out above for the possible causes.
  2415.  
  2416. 8.2 GCC can't find C++ headers
  2417. ==============================
  2418.  
  2419. **Q*: I installed all the packages, but GCC complains it can't find
  2420. `iostream.h', `_string.h' and other C++ headers.  Where can I find those
  2421. header files?*
  2422.  
  2423. **Q*: GCC complains about being unable to find `Complex.h', `Regex.h' and
  2424. other header files which start with a capital letter, and I indeed don't see
  2425. them in my `lang/cxx/' directory.  Where are they?*
  2426.  
  2427. **Q*: My C++ program needs header files whose filenames exceed the 8+3 DOS
  2428. filename restrictions, like `stdiostream.h' and `streambuf.h', and GCC cannot
  2429. find those files.  How in the world can I write portable C++ programs??*
  2430.  
  2431. *A* :  C++ include files are in the file lgp271b.zip, e.g.
  2432. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/lgp271b.zip, so if you
  2433. didn't install it, GCC won't find them.  Files whose names usually start with
  2434. a capital letter, on MS-DOS have an underscore `_' prepended so they can be
  2435. distinguished from `complex.h', `regex.h' and the like under case-insensitive
  2436. DOS.  Change `Complex.h' to `_complex.h' in your source, and GCC will find
  2437. them.
  2438.  
  2439. Another possible cause for problems with C++ include files is that your
  2440. source file has a `.c' extension.  GCC then thinks that this is a C program
  2441. and doesn't instruct the preprocessor to search the include directories
  2442. specific to C++.  Rename your file to `.cc' or `.cpp' extension, or call GCC
  2443. with the `-x c++' switch, and the header files will be found.  A full list of
  2444. extension rules which GCC uses to determine the source language can be found
  2445. in the list of language-specific suffixes in Which language, elsewhere in
  2446. this FAQ.
  2447.  
  2448. If you have problems with header files with long filenames, and you run under
  2449. Win95 or some other environment which allows for long filenames, try
  2450. disabling the "Long File Names" (LFN) support in DJGPP, by setting the `LFN'
  2451. environment variable to `No', like this:
  2452.  
  2453.        set LFN=n
  2454.  
  2455. (DJGPP comes with LFN disabled by default on the `DJGPP.ENV' file, but you
  2456. might have enabled it.)  If this makes the problems go away, then you have
  2457. some conflict between the way LFN is supported by DJGPP and your environment.
  2458. Under Win95, you must rename the files which should have long filenames to
  2459. those long names (as opposed to the truncated names you find in the DJGPP
  2460. archives).  You must also set the option in the Win95 registry which disables
  2461. name-munging of the files which have exactly 8 characters in their name part.
  2462. This is how:
  2463.  
  2464.    * From the "Start" menu select "Run" and type `regedit', to start the
  2465.      Registry Editor.
  2466.  
  2467.    * Expand the `HKEY_LOCAL_MACHINE' branch of the registry until you see in
  2468.      the left pane an item called
  2469.      `HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\FileSystem', then
  2470.      click on it.
  2471.  
  2472.    * The right pane now shows the list of values assigned to the `FileSystem'
  2473.      key.  If you don't see an item there called `NameNumericTail', select
  2474.      "New", "Binary Value" from the "Edit" menu, then type `NameNumericTail'
  2475.      and it will appear.  Now double-click on `NameNumericTail' and enter a
  2476.      value of 0.
  2477.  
  2478.    * Restart Windows 95.
  2479.  
  2480. If the `NameNumericTail' set to 0 breaks some programs, you can restore its
  2481. original setting after you've renamed the files as described above.
  2482. `NameNumericTail' only affects the short names of new files being created, it
  2483. has no effect on the files that already exist.
  2484.  
  2485. 8.3 GCC barfs on C++-style comments in C programs
  2486. =================================================
  2487.  
  2488. **Q*: My C program compiles OK with Borland's C, but GCC complains about
  2489. "parse error before `/' " at a line where I have a "//"-style comment.*
  2490.  
  2491. *A* :  That's because // isn't a comment neither in ANSI C nor in K&R C.
  2492. Borland and Microsoft C compilers support it as an extension.  GCC also
  2493. supports this extension (beginning with version 2.7.0), but using the `-ansi'
  2494. or `-traditional' switches to GCC disables this extension.  In general, it's
  2495. a bad practice to use this extension in a portable program until such time as
  2496. the ANSI C standard includes it.  If it's a C++ program, then rename it to
  2497. have a suffix which will cause gcc to compile it as such (see list of
  2498. language-specific suffixes in Section 8.4), or use `-x c++' switch.  If it's
  2499. a C program, but you want to compile it as C++ anyway, try `-x c++'; it can
  2500. help, but can also get you in more trouble, because C++ has its own rules.
  2501. For example, the following program will print 10 if compiled as a C program,
  2502. but 5 if compiled as C++:
  2503.  
  2504.          #include <stdio.h>
  2505.      
  2506.          int
  2507.          main ()
  2508.          {
  2509.            printf ("%d \n" 10    //*
  2510.                   / 2    //*/
  2511.                     1
  2512.                     );
  2513.            return 0;
  2514.          }
  2515.  
  2516. (While admittedly perverse, this little monstrosity was written with the sole
  2517. purpose of demonstrating that C and C++ have quite different semantics under
  2518. certain circumstances.)
  2519.  
  2520. If you must have both `-ansi' and C++-style comments, you can use the
  2521. `-lang-c-c++-comments' preprocessor switch.  Gcc doesn't accept the
  2522. `-lang-XXX' switches on its command line, so you will have to use the `-Wp'
  2523. option, like this:
  2524.  
  2525.       gcc -c -Wp,-lang-c-c++-comments myprog.c
  2526.  
  2527. Alternatively, you can add `-lang-c-c++-comments' to the `*cpp:' section of
  2528. your `lib/specs' file (but that will make it permanent).
  2529.  
  2530. Bottom line: until the future ANSI/ISO C standard includes this as part of
  2531. the C language, it's best to change those comments to C-style ones, if you
  2532. really mean to write a C program.  The following `Sed' command will convert a
  2533. C program with C++-style comments into a valid C source, provided you don't
  2534. have the string "//" in a character string:
  2535.  
  2536.       sed "s?//\(.*\)?/*\1 */?" file.c > newfile.c
  2537.  
  2538. Sed can be found in the DJGPP distribution, e.g.
  2539. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/sed118b.zip.
  2540.  
  2541. 8.4 How does GCC recognize the source language?
  2542. ===============================================
  2543.  
  2544. **Q*: I type `GCC PROG.CC' and GCC complains that it can't recognize
  2545. `PROG.CC''s file format.  How come a C++ compiler doesn't recognize a C++
  2546. source??*
  2547.  
  2548. **Q*: I type `GCC PROG.C' to compile a C program which I already remember to
  2549. pass compilation without a single warning, and suddenly it gives all kinds of
  2550. strange error messages and unresolved externals.*
  2551.  
  2552. *A* :  That's because you typed your source file extension in *upper* case.
  2553. GCC is *not* case-insensitive about filenames like DOS is, and it uses the
  2554. file's extension to determine how to compile a file.  Valid extensions are:
  2555.  
  2556. `.cc'
  2557. `.C'
  2558. `.cxx'
  2559. `.cpp'
  2560.      C++ source (passed through cpp).
  2561.  
  2562. `.c'
  2563.      C source that must be passed through cpp first.
  2564.  
  2565. `.i'
  2566.      Raw C source (no cpp pass).
  2567.  
  2568. `.ii'
  2569.      Raw C++ source (not to be preprocessed).
  2570.  
  2571. `.m'
  2572.      Objective-C source.
  2573.  
  2574. `.S'
  2575.      Assembler that must be passed through cpp first.
  2576.  
  2577. `.s'
  2578.      Raw assembler source (no cpp pass).
  2579.  
  2580. Any other file is passed to the linker, under the assumption that it's an
  2581. object file.
  2582.  
  2583. In the examples above, `PROG.C' is taken as a C++ program, not a C one, and
  2584. `PROG.CC' is passed to the linker as if it were an object file.  You can see
  2585. what GCC does by adding the `-v' switch to the GCC command line; if you see
  2586. that it's invoking `cc1plus.exe' (the C++ compiler) instead of `cc1.exe' (the
  2587. C compiler), or calling `ld.exe' (the linker) on a source file, then you'd
  2588. know this is your problem.  If you have problems keeping up with the verbose
  2589. GCC output caused by `-v', see how to capture GCC output in Section 6.10, in
  2590. this FAQ.
  2591.  
  2592. You can override the default rules gcc uses to decide how each input file
  2593. should be treated, with the help of the `-x LANGUAGE' switch.  For instance,
  2594. the command
  2595.  
  2596.       gcc -x c++ prog.c
  2597.  
  2598. compiles `prog.c' as C++ source.  See -x LANGUAGE switch description in "The
  2599. GNU C Compiler Manual", or point your Web browser to
  2600. http://www.delorie.com/gnu/docs/gcc/gcc_8.html#SEC11, for more info on `-x'
  2601. options.
  2602.  
  2603. 8.5 Problems with Objective C
  2604. =============================
  2605.  
  2606. **Q*: How do I tell gcc my .cc file is to be compiled as Objective-C source?*
  2607.  
  2608. **Q*: I compile an Objective-C program, but get unresolved symbols.*
  2609.  
  2610. **Q*: I can't compile the Objective-C test program which came with DJGPP.*
  2611.  
  2612. *A* :  Give your sources the `.m' extension, or use `-x objective-c' switch
  2613. to GCC, so it will *know* you mean to compile with Objective C.
  2614.  
  2615. Objective-C was broken in GCC 2.6.0.  The problem manifests itself by
  2616. unresolved modules.  If you use that version, you'll have to upgrade to
  2617. version 2.6.3 or higher.
  2618.  
  2619. 8.6 Writing codes fragments which are specific to DJGPP
  2620. =======================================================
  2621.  
  2622. **Q*: I must put a DJGPP-specific code fragment into my program.  What symbol
  2623. should I use in the `#ifdef' directive to make it only visible under DJGPP?*
  2624.  
  2625. *A* :  Use `__DJGPP__', like this:
  2626.  
  2627.          #ifdef __DJGPP__
  2628.          ... DJGPP-specific code ...
  2629.          #else
  2630.          ... not seen under DJGPP ...
  2631.          #endif
  2632.  
  2633. `__DJGPP__' has the value of the DJGPP major revision number, so you can
  2634. write code fragments which have different behavior under different versions
  2635. of DJGPP:
  2636.  
  2637.          #ifdef __DJGPP__
  2638.          #if __DJGPP__ > 2
  2639.          .... will work only in DJGPP v3.x and later ...
  2640.          #else
  2641.          .... get here for DJGPP v2.x ...
  2642.          #endif
  2643.          #else
  2644.          .... get here in DJGPP v1.x or non-DJGPP environment
  2645.          #endif
  2646.  
  2647. Another DJGPP-specific pre-processor symbol which DJGPP defines is
  2648. `__GO32__'; but it is only provided for compatibility with previous versions
  2649. of DJGPP (v1.x) and its use should be discouraged.
  2650.  
  2651. 8.7 Unresolved externals when linking programs
  2652. ==============================================
  2653.  
  2654. **Q*: Why do I get so many unresolved symbols when linking my programs?*
  2655.  
  2656. *A* :  By default, GCC instructs the linker to only look in two libraries:
  2657. `libgcc.a' and `libc.a.'  Some functions aren't included there, so the linker
  2658. can't find them.  If you need to link against some optional library, say
  2659. `libxy.a', put the library into the DJGPP `lib/' subdirectory and append a
  2660. `-lxy' to the link command line.  To use C++ classes in the `libgpp.a' (it's
  2661. called `libg++.a' on Unix systems), append `-lgpp.'  The Standard C++
  2662. Template classes are in `libstdcx.a' (it's called `libstdc++.a' on Unix);
  2663. append `-lstdcxx.'
  2664.  
  2665. When linking C++ programs, you can use the `gxx' command instead of `gcc'; it
  2666. will then instruct the linker to also scan the C++ libraries automatically,
  2667. so you don't have to remember doing that yourself.
  2668.  
  2669. Note that the first release of DJGPP v2.0 didn't include `gxx.exe' and the
  2670. C++ STL library `libstdcx.a.'  If you cannot find them on your machine,
  2671. download the latest `gcc272b.zip' and `lgp271b.zip' archives that are dated
  2672. 22-Feb-96 or later, or upgrade to DJGPP v2.01.
  2673.  
  2674. If your program uses a lot of floating-point math, or needs math functions
  2675. beyond those specified in the ANSI/ISO standard, consider appending `-lm' to
  2676. your link command line.  The basic math functions required by ANSI/ISO
  2677. standard are included in the `libc.a' library, but `libm.a' includes higher
  2678. quality versions of these functions, and also some functions not included in
  2679. the default library, like Gamma function and Bessel functions.
  2680.  
  2681. 8.8 How not to lose your head with all these libraries
  2682. ======================================================
  2683.  
  2684. **Q*: I'm lost with all those different libraries.  How in the world can I
  2685. find out which functions are included in which library?*
  2686.  
  2687. *A* :  You can use the `nm' program to check what functions are included in a
  2688. library.  Run it with the `-C' option and with the library as its argument
  2689. and look in the output for the name of your function (the `-C', or
  2690. `--demangle' option makes the function names look closer to what they are
  2691. called in the source file).  Functions which have their code included in the
  2692. library have a capital `T' before their name.  For example, the following is
  2693. a fragment from the listing produced by `nm':
  2694.  
  2695.          c:\djgpp\lib> nm --demangle libc.a
  2696.          .
  2697.          .
  2698.          .
  2699.          stdio.o:
  2700.          000000e4 b .bss
  2701.          000000e4 d .data
  2702.          00000000 t .text
  2703.          00000098 t L12
  2704.          0000001e t L3
  2705.          00000042 t L6
  2706.          0000004d t L7
  2707.          0000006a t L9
  2708.          00000000 t __gnu_compiled_c
  2709.               U _filbuf
  2710.               U _flsbuf
  2711.          00000000 T clearerr
  2712.          000000ac T feof
  2713.          000000c2 T ferror
  2714.          000000d8 T fileno
  2715.          0000000c T getc
  2716.          00000052 T getchar
  2717.          0000002a T putc
  2718.          0000007c T putchar
  2719.          00000000 t gcc2_compiled.
  2720.          .
  2721.          .
  2722.          .
  2723.  
  2724. Here we see that the module `stdio.o' defines the functions `clearerr',
  2725. `feof', `ferror', `fileno', `getc', `getchar', `putc' and `putchar', and
  2726. calls functions `_filbuf' and `_flsbuf' which aren't defined on this module.
  2727.  
  2728. Alternatively, you can call `nm' with the `-s' or `--print-armap', which will
  2729. print an index of what symbols are included in what modules.  For instance,
  2730. for `libc.a', we will see:
  2731.  
  2732.          c:\djgpp\lib> nm --print-armap libc.a
  2733.          .
  2734.          .
  2735.          .
  2736.          _feof in stdio.o
  2737.          _ferror in stdio.o
  2738.          _fileno in stdio.o
  2739.          .
  2740.          .
  2741.          .
  2742.  
  2743. which tells us that the functions `feof', `ferror' and `fileno' are defined
  2744. in the module `stdio.o.'
  2745.  
  2746. `nm' is fully described in the GNU docs. See the Binutils package docs in
  2747. "GNU Binutils Manual", or point your Web browser to
  2748. http://www.delorie.com/gnu/docs/binutils/binutils_6.html#SEC5.
  2749.  
  2750. 8.9 DJGPP uses a one-pass linker
  2751. ================================
  2752.  
  2753. **Q*: I give all the libraries to gcc, but I still get unresolved externals
  2754. when I link.  What gives?*
  2755.  
  2756. *A* :  `Ld' is a one-pass linker:  it only scans each library once looking
  2757. for unresolved externals it saw *until that point*.  This means the relative
  2758. position of object files and libraries' names on the command line is
  2759. significant.  You should put all the libraries *after* all the object files,
  2760. and in this order:
  2761.  
  2762.       -lgpp -lstdcxx -lm
  2763.  
  2764. E.g., to link files main.o and sub.o into a C++ library, use the following
  2765. command line:
  2766.  
  2767.       gcc -o main.exe main.o sub.o -lgpp -lstdcxx
  2768.  
  2769. or, if you compile and link in one command:
  2770.  
  2771.       gcc -o main.exe main.cc sub.cc -lgpp -lstdcxx -lm
  2772.  
  2773. If you have any libraries of your own, put them *before* the above system
  2774. libraries, like this:
  2775.  
  2776.       gcc -o main.exe main.cc sub.cc -lmylib -lgpp -lstdcxx -lm
  2777.  
  2778. When you use the `gxx' compilation driver to compile a C++ program, it names
  2779. the C++ libraries in the correct order.
  2780.  
  2781. If your installation tree is different from the default, i.e., if you keep
  2782. the libraries *not* in the default `lib/' subdirectory, then you should add
  2783. that directory to the line in the `[gcc]' section of your `DJGPP.ENV' file
  2784. which starts with `LIBRARY_PATH', or put into your environment a variable
  2785. called `LIBRARY_PATH' and point it to the directory where you keep the
  2786. libraries.  Note that if you invoke the linker by itself (not through the gcc
  2787. driver), then `LIBRARY_PATH' will have no effect, because this variable is
  2788. only known to the gcc driver.  So if you must call `ld' directly, use the
  2789. `-L' option to tell it where to look for the libraries.
  2790.  
  2791. 8.10 C++ functions still not found
  2792. ==================================
  2793.  
  2794. **Q*: I put all the libraries in the above order, but the linker still can't
  2795. find some C++ functions from `complex.h' and `iostream.h.'*
  2796.  
  2797. *A* :  These functions are declared `inline' and defined on these header
  2798. files.  However, GCC won't inline them unless you compile with optimizations
  2799. enabled, so it tries to find the compiled version of the functions in the
  2800. library.  Workaround: compile with `-O.'
  2801.  
  2802. 8.11 Where is class Complex?
  2803. ============================
  2804.  
  2805. **Q*: I cannot use class Complex in v2!  My C++ program compiled fine with
  2806. DJGPP v1.x, but in v2 the linker complains that it cannot find Complex class
  2807. definitions in the library.  Where are they?*
  2808.  
  2809. **Q*: I looked into libgpp.a and there aren't any references to any Complex
  2810. class functions.  I also didn't find complex.cc source file in the source of
  2811. Libg++ library.  Where did the Complex class go?*
  2812.  
  2813. *A* :  The latest Draft C++ Standard has changed its notion of complex
  2814. numbers, and the latest versions of Libg++ have followed suit.  Instead of
  2815. `class Complex' there is now a *template* `class complex<double>', and
  2816. `Complex' is now a typedef which uses that template class.  Look into the
  2817. headers `lang/cxx/_complex.h' and `lang/cxx/std/complext.h' and you will see
  2818. that change.  Part of the code found previously on `complex.cc' in the Libg++
  2819. source distribution is now found on `cdinst.cc' source file in the STL
  2820. sources (look inside `libstdcx.a'), another part is scattered between the
  2821. various files included at compile time (such as `lang/cxx/std/dcomplex.h' and
  2822. `lang/cxx/std/complext.cc'), while the rest is generated by the compiler
  2823. itself.  Therefore, there aren't any predefined functions of class Complex in
  2824. `libgpp.a.' Programs that use class Complex need to be edited to replace every
  2825. instance of `class Complex' to either just `Complex' or `class
  2826. complex<double>.'
  2827.  
  2828. As long as the C++ Standard is not officially published, C++ is still a
  2829. moving target, and Libg++ releases that try to track it sometimes have no
  2830. other alternative but to break existing code.  If you use C++, you have to
  2831. accept this as a fact of life.
  2832.  
  2833. 8.12 The linker complains about __pure_virtual function.
  2834. ========================================================
  2835.  
  2836. **Q*: When I link a C++ program, the linker complains about "__pure_virtual"
  2837. being an unresolved symbol.  What should I do?*
  2838.  
  2839. *A* :  This problem is caused by a `libgcc.a' library which lacks a module
  2840. called `___pure_virtual' (yes, with *three* leading underscores!).  You
  2841. should get an updated version of that library which includes such a module.
  2842. `libgcc.a' comes with the Gcc distribution, so look in the latest
  2843. `gccNNNb.zip' file.
  2844.  
  2845. If, for some reason, you cannot find `libgcc.a' with that module, you can add
  2846. it yourself.  To this end, create a file called `pure.c' with this content:
  2847.  
  2848.      #define MESSAGE "pure virtual method called\n"
  2849.      
  2850.      void __pure_virtual()
  2851.      {
  2852.          write(2, MESSAGE, sizeof(MESSAGE) - 1);
  2853.          _exit(-1);
  2854.      }
  2855.  
  2856. Compile this file and put the object file into `libgcc.a', like this:
  2857.  
  2858.              gcc -c pure.c
  2859.              ar rvs libgcc.a pure.o
  2860.  
  2861. That's all!
  2862.  
  2863. 8.13 Unresolved djgpp_first_ctor
  2864. ================================
  2865.  
  2866. **Q*: I do everything like your praised FAQ says, but the linker complains
  2867. about unresolved symbols with strange names like `djgpp_first_ctor',
  2868. `djgpp_last_dtor', etc.  I looked in every library with `nm', and I cannot
  2869. find these creatures.  Where in the world are they??*
  2870.  
  2871. *A* : These symbols are defined by the `djgpp.djl' linker script that should
  2872. be in your `lib/' subdirectory.  When you call `gcc' to link a program, it
  2873. invokes `ld.exe' with the option `-Tdjgpp.djl.'  If you invoke `ld' directly
  2874. (this is generally not recommended), be sure to include that switch.  If you
  2875. did invoke it through `gcc', maybe your linker is set up incorrectly.  Add
  2876. `-v' to the GCC switches and check that the command line that GCC gives to LD
  2877. includes that switch, that your `lib/' subdirectory includes that script
  2878. file, and that the script file is intact and includes the definition of the
  2879. above symbols.
  2880.  
  2881. Another reason might be that you have edited your `DJGPP.ENV' file in a way
  2882. that prevents the linker from finding its `djgpp.djl' script.
  2883.  
  2884. Mixing an old v1.x installation with a v2.x one can also cause such problems.
  2885. Be sure to delete the entire v1.x tree, or rename it, before installing the
  2886. v2.x distribution.
  2887.  
  2888. 8.14 C++ programs yield large `.exe' file
  2889. =========================================
  2890.  
  2891. **Q*: It seems that declaring a large `static' array has the effect of
  2892. bloating the program image on disk by that many bytes.  Surely there is a
  2893. more compact way of telling the loader to set the next N bytes of RAM to
  2894. zero?*
  2895.  
  2896. *A* :  This only happens in C++ programs and is a (mis-)feature of GCC.  You
  2897. can use the `-fconserve-space' switch to GCC to prevent this from happening,
  2898. but it also turns off the diagnostics of duplicate definitions, which, if
  2899. uncaught, might cause your program to crash.  Thus, this switch isn't
  2900. recommended for programs which haven't been completely debugged (if there is
  2901. such a creature).  The `-fconserve-space' switch is described in the GCC
  2902. docs, See GNU C Compiler docs in "GNU C Compiler Manual", or point your Web
  2903. browser to http://www.delorie.com/gnu/docs/gcc/gcc_11.html#SEC14.
  2904.  
  2905. If the downside of using this switch doesn't deter you, you can even add this
  2906. switch to your `lib/specs' file to make it permanent.
  2907.  
  2908. 8.15 Why are DJGPP `.exe' files so large?
  2909. =========================================
  2910.  
  2911. **Q*: I compiled a trivial "Hello world" program and got a 60KB executable
  2912. file.  That's ridiculously bloated!*
  2913.  
  2914. **Q*: How come I recompile my programs with v2, and my executables become
  2915. larger by some 20-30 KBytes?  Isn't the latest version supposed to be better?*
  2916.  
  2917. *A* :  Did you link with `-s' switch to `gcc', or run `strip' on the output
  2918. of the linker?  If not, the executable includes the debugging symbols, which
  2919. makes it quite a lot larger.  (It is not recommended to strip the symbols
  2920. except when distributing production programs, because this makes debugging
  2921. very hard indeed; that is why `-s' is not passed to gcc by default.)
  2922.  
  2923. In general, v2 programs are about 20-30K larger on disk, but use 50-120K less
  2924. memory at run-time, than v1.x programs.  The larger disk image is due to two
  2925. main factors:
  2926.  
  2927.    * Part of the code that used to be inside `go32' DOS extender in v1.x is
  2928.      now part of the library and thus gets linked into every program.
  2929.  
  2930.    * The v2 startup code is much more powerful, but also larger.
  2931.  
  2932. Judging code sizes by looking at the size of "Hello" programs is meaningless,
  2933. since most of the power of protected-mode programming goes wasted in such
  2934. programs.  There is no point in switching the processor to protected mode
  2935. (which requires a lot of code) just to print a 15-byte string and exit.  The
  2936. overhead induced by the code needed to set up the protected-mode environment
  2937. is additive; the larger the program, the smaller the overhead relative to the
  2938. program size.
  2939.  
  2940. Apart from getting to protected-mode, the DJGPP startup code also includes
  2941. such functionality as wildcard expansion, long command-line support, and
  2942. loading the environment from a disk file; these usually aren't available with
  2943. other DOS protected-mode compilers.  Exception and signal handling (not
  2944. available at all in v1.x), FPU detection and emulator loading (which were
  2945. part of `go32' in v1.x), are now also part of the startup code.
  2946.  
  2947. If your program doesn't need parts of the startup code, it can be made
  2948. smaller by defining certain functions with empty bodies.  These functions are
  2949. `__crt0_glob_function', `__crt0_load_environment_file', and
  2950. `__crt0_setup_arguments.' By defining empty substitutes for all three of
  2951. these, you can make the "Hello" program be 18KB on disk.  These functions are
  2952. documented in the DJGPP libc reference, which see.
  2953.  
  2954. You can make your program image still smaller by compressing it with `DJP'
  2955. which is a DJGPP-specific executable compressor, e.g.
  2956. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2misc/mlp105b.zip.  It is fast
  2957. and has no memory overhead.  It also supports DJGPP "Dynamically Loaded
  2958. Module" (DLM) technology.
  2959.  
  2960. Another cause for differences in executable sizes between v1.x and v2 might
  2961. be the code generated by GCC: DJGPP v2 uses a newer version of GCC.  Usually,
  2962. the code size is quite similar, but in some cases GCC 2.7.2 has been seen to
  2963. produce code which is 50% larger or 50% smaller than GCC 2.6.3 included with
  2964. v1.12.
  2965.  
  2966. 8.16 Linker complains about `djgpp.lnk'
  2967. =======================================
  2968.  
  2969. **Q*: I run DJGPP under Windows 95, but the linker complains about
  2970. `djgpp.lnk' file...*
  2971.  
  2972. **Q*: When I try to link a program, I get an error message which says that
  2973. linker script file djgpp.lnk cannot be open.  What gives?*
  2974.  
  2975. *A* :  Do you use DJGPP v2.0 on Windows 9x and have a shortcut to DJGPP in
  2976. your current directory?  If so, and if you call that shortcut `djgpp',
  2977. Windows will create a file `djgpp.lnk' in your working directory.  In that
  2978. case, when `ld.exe' looks for its linking script, it will find this shortcut
  2979. instead, and will be totally confused by its format and contents.  In DJGPP
  2980. v2.01 and later, the linker script is called `djgpp.djl', so that this
  2981. conflict doesn't exist after you upgrade.
  2982.  
  2983. Another possible cause of such problems is RSXNTDJ.  When you install it, it
  2984. replaces some of the files which come with DJGPP by its customized versions,
  2985. but since version 1 of RSXNTDJ is consistent with DJGPP v2.0, these
  2986. customized files still specify `djgpp.lnk' as the linker script, whereas
  2987. DJGPP v2.01 and later has renamed that file to `djgpp.djl'.  Please look into
  2988. your `rsxntdj/lib/specs' file and see if it has a line like so:
  2989.  
  2990.        %{L*} %D %{T*} %o -Tdjgpp.lnk\
  2991.  
  2992. If so, you should change `-Tdjgpp.lnk' into `-Tdjgpp.djl', and see if that
  2993. solves the problem, or look for a version of RSXNTDJ which is compatible with
  2994. your release of DJGPP.  You should also compare the rest of the RSXNTDJ
  2995. `specs' file with the one which comes with DJGPP and check for other
  2996. inconsistencies.
  2997.  
  2998. 8.17 Linker fails to produce the EXE program under Novell
  2999. =========================================================
  3000.  
  3001. **Q*: When I link my program, it fails to produce the .EXE executable, but
  3002. only if I do this on a networked drive...*
  3003.  
  3004. **Q*: I run STUBIFY on a networked drive under Novell, but it doesn't produce
  3005. a .EXE file.  How come?*
  3006.  
  3007. *A* :  You might have another copy of the file with the same name that GCC is
  3008. creating in another directory somewhere on your networked drive.  If that
  3009. other directory is on your PATH, it is searched by Novell when the linker and
  3010. `STUBIFY' try to create the executable file, because that file doesn't exist
  3011. in the current directory.  So what might actually happen is that the linker
  3012. and `STUBIFY' are overwriting the files they find on your PATH instead of
  3013. creating new files in the current directory.
  3014.  
  3015. You can verify that this indeed is the problem by searching your networked
  3016. disks for files with the same name as those you are trying to build, and
  3017. looking at their time stamps.  If that is indeed the problem, then you have
  3018. several possible ways of solving it:
  3019.  
  3020.   1. You can remove the other files, rename them, or move them to another
  3021.      directory that isn't searched by Novell.
  3022.  
  3023.   2. You can rename the program you are trying to link.
  3024.  
  3025.   3. You can change the way Novell searches for files (aka "the search
  3026.      mode"), so that it won't look in the directories on your PATH.
  3027.  
  3028.   4. You can change your access rights to the directory on the PATH where the
  3029.      other files reside, so that you won't have write privileges to that
  3030.      directory.
  3031.  
  3032.   5. You can change the search mode for `STUBIFY' and the linker (or for any
  3033.      other program that gives you that trouble) by running commands like
  3034.      these:
  3035.  
  3036.             SMODE stubify.exe 2
  3037.             SMODE ld.exe 2
  3038.  
  3039.  
  3040. 8.18 Linker fails for large object files or large libraries
  3041. ===========================================================
  3042.  
  3043. **Q*: Whenever I define very large static arrays in my program, the linker
  3044. fails saying "could not read symbols: Bad value".  Huh??*
  3045.  
  3046. **Q*: I have some large libraries that I cannot link because the linker fails
  3047. on them with a message saying "memory exhausted".  I have plenty of virtual
  3048. memory on my system, so why would ld fail?*
  3049.  
  3050. *A* :  This is a known bug in `ld.exe' from GNU Binutils 2.5.2.  Please
  3051. upgrade to DJGPP v2.01 which comes with Binutils 2.7.  If you can't upgrade,
  3052. or if the latest `ld.exe' exhibits such bugs, these are your alternatives for
  3053. a work-around:
  3054.  
  3055.    * In case of a large library, split it into several smaller ones.
  3056.  
  3057.    * For a module that defines large data structures, move some of the static
  3058.      data to other files, or allocate the space at runtime with `calloc.'
  3059.  
  3060. `ld.exe' from GNU Binutils 2.7 (which comes with DJGPP v2.01) doesn't have
  3061. most of these problems, but there are still some cases where you might see
  3062. such messages.  One such case is the `POVRAY' package, where the failure is
  3063. caused by an object file called `_pmlite.o' in the library.  The problem here
  3064. is that `_pmlite.o' is a TASM-compiled file, processed by `EMXAOUT'.
  3065. `EMXAOUT' produces `a.out' object files which `ld.exe' cannot link if they
  3066. are in a library.  Either taking that object file out of the library, or
  3067. processing the original `_pmlite.obj' with another tool (such as `OBJ2COFF')
  3068. will solve these problems.  Note however, that the authors of `OBJ2COFF' have
  3069. explicitly forbidden commercial use of their tool.
  3070.  
  3071. 8.19 Building Allegro library fails
  3072. ===================================
  3073.  
  3074. **Q*: When I try to build the Allegro library, liballeg.a, I get some cryptic
  3075. message about register-opcode mismatch.  What am I doing wrong?*
  3076.  
  3077. **Q*: It seems I miss one of the source files from the Allegro distribution,
  3078. because Make cannot find it when I try to build Allegro.*
  3079.  
  3080. *A* :  You should get the latest version 2.11 of Allegro from SimTel.NET,
  3081. e.g. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2tk/alleg211.zip or from
  3082. Shawn Hargreaves' site, at this URL:
  3083.  
  3084.      http://www.talula.demon.co.uk/allegro/
  3085.  
  3086. Version 2.1 of Allegro and some uploads of 2.11 to sites other than
  3087. SimTel.NET are known to have bugs such as above.
  3088.  
  3089. 9. Running Compiled Programs
  3090. ****************************
  3091.  
  3092.   This chapter discusses various problems which may happen when running DJGPP
  3093. programs under different environments, and gives solutions to them.
  3094.  
  3095. 9.1 My program crashes only in v2.0!
  3096. ====================================
  3097.  
  3098. **Q*: I have this program which runs fine when compiled with DJGPP v1.12, but
  3099. crashes and burns in v2.  Isn't it obvious that you guys blew it with v2?*
  3100.  
  3101. **Q*: My v2 program crashes, but only under CWSDPMI; it runs OK under other
  3102. DPMI hosts like Windows, OS/2 or QDPMI.  Is this a bug in CWSDPMI?*
  3103.  
  3104. *A* :  Not necessarily so, it could still be a bug in your program which just
  3105. went unnoticed until now.  One area where such things can happen is use of
  3106. uninitialized memory.  In v1.x, memory first allocated to the stack or by a
  3107. call to `malloc' is always zeroed, but v2 doesn't behave this way, so your
  3108. program might exhibit erratic behavior or crash with `SIGSEGV' because of
  3109. such bugs.  In particular, if the program behaves differently depending on
  3110. which program was run before it, you might suspect bugs of this kind.
  3111.  
  3112. To check whether this is the source of your grief, include the header
  3113. `crt0.h' in your `main' and set `_crt0_startup_flags' to
  3114. `_CRT0_FLAG_FILL_SBRK_MEMORY'; this will fill the memory with zeroes when it
  3115. is first allocated.  If the program will run OK after recompilation, then
  3116. this is probably the cause of your problem.  To make spotting uninitialized
  3117. memory simpler, you can set `_crt0_startup_flags' to
  3118. `_CRT0_FLAG_FILL_DEADBEAF' (don't laugh!); this will cause the sbrk()'ed
  3119. memory to be filled with the value `0xdeadbeaf' (`-559838801' in decimal)
  3120. which is easy to spot with a debugger.  Any variable which has this value was
  3121. used without initializing it first.
  3122.  
  3123. Another possible cause of problems will most probably be seen only under
  3124. CWSDPMI; its telltale sign is a message "Page fault at ..." that is printed
  3125. when a program crashes, and an error code of 6.  Unlike other DPMI hosts,
  3126. CWSDPMI supports some DPMI 1.0 extensions which allow DJGPP to capture and
  3127. disallow illegal dereference of pointers which point to addresses less than
  3128. 1000h (aka "NULL pointer protection").  This feature can be disabled by
  3129. setting the `_CRT0_FLAG_NULLOK' bit in `_crt0_startup_flags'; if this makes
  3130. SIGSEGV crashes go away, your program is using such illegal pointers; the
  3131. stack trace printed when the program crashes should be a starting point to
  3132. debug this.
  3133.  
  3134. An insufficient stack size can also be a cause of your program's demise, see
  3135. setting the stack size in Section 15.9, below.
  3136.  
  3137. 9.2 What is that gibberish printed when my program crashes?
  3138. ===========================================================
  3139.  
  3140. **Q*: My program dies with a cryptic message like "Segmentation violation" or
  3141. "Unsupported DOS request" or "General Protection Fault" and prints some
  3142. funny-looking numbers.  Can't I get some decent human-readable traceback
  3143. information, so I could pinpoint where in the program did the problem happen?*
  3144.  
  3145. *A* :  Those "funny-looking numbers" *are* the traceback.  They describe the
  3146. sequence of function calls which led to the fatal error by giving you the
  3147. addresses where each function was called.  You can have these addresses
  3148. translated to source line numbers by using the `SYMIFY' program (it is
  3149. included in the djdev201.zip, e.g.
  3150. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2/djdev201.zip, and should be
  3151. in your `bin/' subdirectory).  To this end, make sure that your program was
  3152. compiled with the `-g' switch, linked *without* the `-s' switch and *not*
  3153. stripped, and that you have the source files available in your current
  3154. directory.  Now invoke your program and do whatever it takes to make it
  3155. crash.  Then, with the traceback still on the screen, type this from the DOS
  3156. command line:
  3157.  
  3158.       symify your-program-name
  3159.  
  3160. You will see the list of source files and line numbers right next to their
  3161. hex addresses.  Now you can start debugging.
  3162.  
  3163. You can ask `SYMIFY' to put the stack trace into a file (so you can consult
  3164. it later, e.g., from your editor while fixing the bug), by giving it an
  3165. output file, like this:
  3166.  
  3167.       symify -o problem.dmp yourprog
  3168.  
  3169. You can also save the raw stack trace (without source info) to a disk file
  3170. and submit it to `SYMIFY' later, like this:
  3171.  
  3172.       symify -i core.dmp yourprog
  3173.  
  3174. This comes in handy when your program grabs the screen (e.g., for some
  3175. graphics) and the stack trace can't be seen.  You can then redirect the stack
  3176. trace to a file in Section 6.10, e.g., with the `REDIR' program which comes
  3177. with DJGPP.
  3178.  
  3179. But what if you *didn't* compile your program with `-g', and you aren't sure
  3180. how to recreate the problem which crashed it, after you recompile?  Well, you
  3181. can submit the stack dump *after* you recompile your program.  Just press
  3182. that PrintScreen key or otherwise save the stack trace, then submit it to
  3183. `SYMIFY' from a file as described above, after you've recompiled the program.
  3184. Be sure to give gcc all the compilation switches (sans `-s') that you gave
  3185. it when you originally compiled your program (in addition to `-g'), including
  3186. the optimization switches, or else the addresses shown in the stack trace
  3187. might be invalid.
  3188.  
  3189. 9.3 Reading and writing binary files
  3190. ====================================
  3191.  
  3192. **Q*: I'm reading/writing data files, but the data gets corrupted.*
  3193.  
  3194. **Q*: My program crashes when I read data files, but the same program on Unix
  3195. works OK.*
  3196.  
  3197. **Q*: When I read a file I get only a small portion of it.*
  3198.  
  3199. *A* :  Are your data files binary?  The default file type in DOS is "text",
  3200. even when you use the `read' and `write' library functions.  Text files get
  3201. their Newlines converted to <CR>-<LF> pairs on write and vice versa on read;
  3202. reading in "text" mode stops at the first <^Z> character.  You must tell the
  3203. system that a file is binary through the `b' flag in `fopen', or `O_BINARY' in
  3204. `open', or use the `setmode' library function.
  3205.  
  3206. Note that the above distinction between binary and text files is written into
  3207. the ANSI/ISO C standard, so programs that rely on the Unix behavior whereby
  3208. there's no such distinction, are strictly speaking not portable.
  3209.  
  3210. You can also use the low-level `_read' and `_write' library functions which
  3211. give you the direct interface to the DOS file I/O; they always use binary I/O.
  3212.  
  3213. 9.4 Buffered screen I/O surprises
  3214. =================================
  3215.  
  3216. **Q*: My program prompts the user to enter data from the keyboard, then reads
  3217. its response.  When compiled with a 16-bit compiler like BCC or MSC it works
  3218. as expected, but with gcc the prompt doesn't show, or is printed much later
  3219. in the program.*
  3220.  
  3221. **Q*: Help!  I cannot make `gotoxy' work!  The text I print appears on the
  3222. screen in incorrect locations after I use `gotoxy'!*
  3223.  
  3224. **Q*: Why does the text appear in the default colors even though I call
  3225. `textcolor' and `textbackground'?*
  3226.  
  3227. *A* :  Do you write to screen using buffered I/O (`fprintf', `fputs' and the
  3228. like) functions, or send your output to the C++ `cout' stream?  Then what you
  3229. see is the effect of the buffering of the standard output streams.  The
  3230. buffer is not written to screen until it's full, or until a Newline is
  3231. output, which might produce very unpleasant and unexpected behavior when used
  3232. in interactive programs.
  3233.  
  3234. It is usually a bad idea to use buffered I/O in interactive programs; you
  3235. should instead use screen-oriented functions like `cprintf' and `cputs.'  If
  3236. you must use buffered I/O, you should be sure that both `stdout' and `stderr'
  3237. are line-buffered or unbuffered (you can change the buffering by calling the
  3238. `setvbuf' library function); another solution would be to `fflush' the output
  3239. stream before calling any input function, which will ensure all pending
  3240. output is written to the operating system.  While this will generally work
  3241. under DOS and DJGPP, note that in some cases the operating system might
  3242. further buffer your output, so sometimes a call like `sync' would be needed
  3243. to actually cause the output be delivered to the screen.
  3244.  
  3245. The functions that set text attributes only affect the screen-oriented output
  3246. (aka "conio") functions (`cputs', `cprintf' etc.), the text written by
  3247. `fprintf' and other "stdio" functions doesn't change.  This is unlike some
  3248. 16-bit DOS compilers where `stdio' functions can also print colored text.
  3249.  
  3250. 9.5 What do DJGPP programs need to run?
  3251. =======================================
  3252.  
  3253. **Q*: When I copy my DJGPP application program to another PC where no DJGPP
  3254. is installed, I can't run it.  It complains that it cannot find DPMI (??).
  3255. Do I really need all of your multi-megabyte installation to run compiled
  3256. programs?*
  3257.  
  3258. *A* :  No, you don't.  You can either (1) bring the `CWSDPMI.EXE' free DPMI
  3259. host to the target machine and put it in the same directory as your compiled
  3260. program or somewhere along the `PATH', or (2) install another DPMI host (such
  3261. as QDPMI, 386Max, Windows, etc.) on the target machine.  Note that the author
  3262. of CWSDPMI, Charles Sandmann <sandmann@clio.rice.edu>, requests a
  3263. notification by mail or acknowledged e-mail in case you distribute CWSDPMI
  3264. with a commercial or shareware product.
  3265.  
  3266. If your program could be run on a machine which lacks a floating-point
  3267. processor, you should also distribute an emulator, or link your program with
  3268. an emulator library.  See floating-point emulation issues in Section 11.1.
  3269.  
  3270. Future DJGPP releases might have a way to bind your executable with `CWSDPMI'
  3271. to produce a stand-alone program.  If you need such a feature *now* and if
  3272. you need it *badly*, write to Charles Sandmann <sandmann@clio.rice.edu> and
  3273. ask him about a modified stub code that creates an image of CWSDPMI if none
  3274. is found first time the program is run.
  3275.  
  3276. You can bind `PMODE/DJ' with your program, but remember that `PMODE/DJ'
  3277. doesn't support virtual memory, so such programs will only run on machines
  3278. with enough free physical RAM.
  3279.  
  3280. 10. Writing and Running Graphics Programs
  3281. *****************************************
  3282.  
  3283.   This chapter discusses some problems and explains some subtle points related
  3284. to graphics programming under DJGPP.
  3285.  
  3286. A tutorial is available on graphics programming with DJGPP, at this URL:
  3287.  
  3288.      http://remus.rutgers.edu/~avly/djgpp.html
  3289.  
  3290. 10.1 What GRX driver to use with your SVGA
  3291. ==========================================
  3292.  
  3293. **Q*: Why won't GRX work with my SVGA adapter in any resolution but the
  3294. standard VGA?*
  3295.  
  3296. **Q*: How do I tell GRX which driver to use with my SVGA?*
  3297.  
  3298. *A* :  In order for GRX to work with your SVGA, you should set the `GRX20DRV'
  3299. environment variable, like this:
  3300.  
  3301.        set GRX20DRV=et4000 gw 1024 gh 768 nc 256
  3302.  
  3303. To set that variable, you need to know the chip-set on your adapter; refer to
  3304. your SVGA documentation.  Currently, GRX supports the following chip-sets:
  3305.  
  3306. `ati28800'
  3307.      The ATi 28800 chip-set.
  3308.  
  3309. `cl5426'
  3310.      Cirrus Logic CL-GD5426 or higher (like CL-GD5428) chip-set.
  3311.  
  3312. `et4000'
  3313.      Tzeng Labs ET4000 chip-set.
  3314.  
  3315. `mach64'
  3316.      The ATi Mach-64 SVGA.
  3317.  
  3318. `stdega'
  3319.      The standard EGA adapter.
  3320.  
  3321. `stdvga'
  3322.      The standard VGA adapter.
  3323.  
  3324. `VESA'
  3325.      For any VESA-compatible adapter.
  3326.  
  3327. After you set the `GRX20DRV' variable, run `modetest.exe' to see what modes
  3328. you have available.
  3329.  
  3330. If your chip-set is not one of the above, try the `VESA' driver because many
  3331. adapters support the VESA BIOS extensions.  If yours doesn't, try installing
  3332. a VESA BIOS emulator, like UNIVBE, e.g.
  3333. ftp://ftp.coast.net/Coast/msdos/graphics/univbe51.zip.
  3334.  
  3335. 10.2 Accessing the video memory
  3336. ===============================
  3337.  
  3338. **Q*: I try to access the video memory at `0xa0000', but get "Segmentation
  3339. violation" ...*
  3340.  
  3341. **Q*: How can I access the text-mode video memory of my VGA?*
  3342.  
  3343. *A* :  Absolute addresses of memory-mapped devices are mapped differently
  3344. under DJGPP than what you might be used to under other DOS development
  3345. environments.  That's because DJGPP is a protected-mode environment, in which
  3346. you can't just poke any address:  that's what protected mode is all about!
  3347. To access such absolute addresses, use the so-called "farptr" functions like
  3348. `_farpeekb' and `_farpokew'; they are described in the C Library reference.
  3349. See more details on using "farptr" functions to access absolute addresses in
  3350. low memory in Section 18.4, below.
  3351.  
  3352. For text-mode screen updates, you can also use the `ScreenUpdate' and
  3353. `ScreenUpdateLine' library functions to quickly update the screen from a text
  3354. buffer.
  3355.  
  3356. Using the `_farpeekX/_farpokeX' paradigm to access memory isn't much slower
  3357. than direct access (they compile into 2 machine instructions when
  3358. optimizations are enabled).  But if you need even faster access (and don't
  3359. want to write it in assembly), See using the "nearptr" access facilities in
  3360. Section 18.4, as described below.
  3361.  
  3362. If your video card supports the VBE 2.0 standard, you can access the linear
  3363. frame buffer as a normal array in memory.  For an example of such a
  3364. technique, see the VBE example code by Charles Sandmann, e.g.
  3365. ftp://ftp.neosoft.com/pub/users/s/sandmann/vbe.zip.  You can also reach this
  3366. file via the Web, at this URL:
  3367.  
  3368.      http://www.rt66.com/~brennan/djgpp/vbe.zip
  3369.  
  3370. 10.3 Graphics screen restoring under Windows
  3371. ============================================
  3372.  
  3373. **Q*: When I switch away from my DJGPP program under Windows, then switch
  3374. back to it, graphics mode is down, or my screen is all messed up.  Why?*
  3375.  
  3376. *A* :  Windows only saves the VGA screen in standard VGA modes (1..13h) when
  3377. you task-switch away from a DOS application.  In any other mode it only
  3378. saves/restores the video mode *number*, but not the actual screen contents.
  3379. Your application is most likely still in the proper video mode (if not, it's
  3380. probably the fault of the Windows driver for your SVGA card), but the video
  3381. memory is messed up.  The beauty of all this is that your program has no way
  3382. of knowing that the screen has been taken away and then returned to it.
  3383.  
  3384. The only reasonable thing to do is to dedicate a "hotkey" in your application
  3385. (e.g., `Alt-R') whose action is to redraw the entire screen.  If you do that,
  3386. it's best to start all the way from the beginning, with a call to
  3387. `GrSetMode', as there are a few bad Windows video drivers which do not
  3388. restore SVGA graphics modes properly upon the switch back.
  3389.  
  3390. 11. Floating Point Issues and FP Emulation
  3391. ******************************************
  3392.  
  3393.   This chapter deals with issues pertaining to floating-point code and
  3394. floating-point emulation under DJGPP.
  3395.  
  3396. 11.1 Floating code without 80387
  3397. ================================
  3398.  
  3399. **Q*: I don't have an 80387.  How do I compile and run floating point
  3400. programs?*
  3401.  
  3402. **Q*: What shall I install on a target machine which lacks hardware
  3403. floating-point support?*
  3404.  
  3405. *A* :  Programs which use floating point computations and could be run on
  3406. machines without an 80387 should either be linked with the `libemu.a'
  3407. emulation library (add `-lemu' to your link command line) or be allowed to
  3408. dynamically load the `emu387.dxe' file at run-time if needed.  Linking with
  3409. libemu makes distribution simpler at a price of adding about 20KB to the size
  3410. of the program `.exe' file (the emulator functions will be used only if no
  3411. hardware floating point support is detected at runtime).  You should *always*
  3412. do one of the above when you distribute floating-point programs.
  3413.  
  3414. A few users reported that the emulation won't work for them unless they
  3415. explicitly tell DJGPP there is no x87 hardware, like this:
  3416.  
  3417.        set 387=N
  3418.        set emu387=c:/djgpp/bin/emu387.dxe
  3419.  
  3420. This is probably due to some subtle bug in the emulator setup code.  This
  3421. code is hard to debug, because the people who developed it have machines with
  3422. hardware FP processors.  Volunteers with FPU-less machines are needed to help
  3423. debug the above problem.  If you have access to a system without an FPU and
  3424. are willing to fix this problem, write to Charles Sandmann
  3425. <sandmann@clio.rice.edu> and ask him for guidance.
  3426.  
  3427. There is an alternative FP emulator called `WMEMU' (get the file
  3428. `v2misc/wmemu2b.zip').  It mimics a real coprocessor more closely, but is
  3429. larger in size and is distributed under the GNU General Public License (which
  3430. generally means you need to distribute its source if you distribute
  3431. `wmemu387.dxe', or distribute the source or objects to your entire program,
  3432. if you link it with `libwmemu.a').  Its advantage is that with `WMEMU', you
  3433. can debug FP apps on a non-FPU machine.  (But you will need to get the
  3434. sources and recompile it, since it was compiled with a beta release of DJGPP
  3435. and will cause unresolved externals if you try linking against `libwmemu.a'
  3436. without recompiling it.)  Note, however, that even `WMEMU' doesn't solve all
  3437. the problems of debugging FP programs on a non-FPU machine (e.g., emulating
  3438. flags doesn't work).
  3439.  
  3440. 11.2 Other FP emulators cannot be used with DJGPP
  3441. =================================================
  3442.  
  3443. **Q*: I have an 80387 emulator installed in my `AUTOEXEC.BAT', but
  3444. DJGPP-compiled floating point programs still doesn't work.  Why?*
  3445.  
  3446. *A* :  DJGPP switches the CPU to *protected* mode, and the information needed
  3447. to emulate the 80387 is different.  Not to mention that the exceptions never
  3448. get to the real-mode handler.  You *must* use emulators which are designed
  3449. for DJGPP.  Apart of `emu387' and `WMEMU', the only other emulator known to
  3450. work with DJGPP is `Q87' from QuickWare.  `Q87' is shareware and is available
  3451. from the QuickWare Web site, at this URL:
  3452.  
  3453.      http://www.weblane.com/quickware
  3454.  
  3455. 11.3 Floating-point emulation under OS/2
  3456. ========================================
  3457.  
  3458. **Q*: I run DJGPP in an OS/2 DOS box, and I'm told that OS/2 will install its
  3459. own emulator library if the CPU has no FPU, and will transparently execute
  3460. FPU instructions.  So why won't DJGPP run floating-point code under OS/2 on
  3461. my machine?*
  3462.  
  3463. *A* :  OS/2 installs an emulator for native OS/2 images, but does not provide
  3464. FPU emulation for DOS sessions.
  3465.  
  3466. 11.4 DJGPP doesn't support `-msoft-float'
  3467. =========================================
  3468.  
  3469. **Q*: I've read in the GCC Info file that gcc has a `-msoft-float' option
  3470. which is said to generate library calls for floating point support.  Can this
  3471. facility be used for FP emulation on a machine without x87?*
  3472.  
  3473. *A* :  The GCC Info file also says that the library required by
  3474. `-msoft-float' is *not* part of the GNU C compiler.  As nobody wrote such a
  3475. library for DJGPP (yet), this option currently isn't supported.
  3476.  
  3477. 11.5 Numeric exceptions--sometimes
  3478. ==================================
  3479.  
  3480. **Q*: I have a program which works with FP emulation, but dies with "Numeric
  3481. Exception" when run on a machine with a co-processor.  It also runs OK when
  3482. compiled with Microsoft C.  Can't you people make your floating-point code
  3483. right?*
  3484.  
  3485. *A* : This might be still a problem with your program.  Under DJGPP, the
  3486. 80x87 control word is set up so that it generates an exception when your
  3487. program feeds it with a "NaN" ("Not a Number"), while the emulator doesn't
  3488. have this behavior.  You should make sure that your program doesn't generate
  3489. NaNs, or set the 80x87 control word to a different value.  A library function
  3490. called `_control87' can be used from within a program to set the coprocessor
  3491. to a non-default state.
  3492.  
  3493. 11.6 Floating point inaccuracies when using emulator
  3494. ====================================================
  3495.  
  3496. **Q*: I am experiencing inaccurate results in some floating point
  3497. calculations, sometimes in the 2nd or 3rd significant digit (like getting
  3498. 118.401 instead of 120.0).  This is really unacceptable!  (And no, I'm *not*
  3499. using a buggy Pentium CPU.)*
  3500.  
  3501. *A* :  Are you using the emulator?  If so, it might be that the emulator
  3502. isn't as accurate as you expect.  One particular known problem is that it
  3503. does a bad job when computing the `atan' function.  So if you use `atan(1.)'
  3504. to get the value of `Pi', that might be your problem.  Solution: make `Pi' a
  3505. constant, as God intended.  The header file `<math.h>' includes the constant
  3506. `M_PI' which you can use; or get the value of Pi from the net, at this URL:
  3507.  
  3508.      http://www.diku.dk/~terra/pi.html
  3509.  
  3510. 11.7 Floating point exception in Objective-C programs
  3511. =====================================================
  3512.  
  3513. **Q*: When I run my Objective-C programs on a machine without an FPU, it dies
  3514. with a floating point exception, even though I installed the emulator as the
  3515. docs say...*
  3516.  
  3517. *A* : There is a bug in GCC 2.7.2 whereby it sometimes emits Objective-C code
  3518. that crashes ObjC programs.  A patch that fixes it was posted to the DJGPP
  3519. news group and can be found in the DJGPP mail archives, at this URL:
  3520.  
  3521.      http://www.delorie.com/djgpp/mail-archives/djgpp/1996/05/05/11:05:21
  3522.  
  3523. You will have to get the GCC source distribution `gcc2721s.zip', install the
  3524. above patch, rebuild `cc1obj.exe', and then recompile `libobjc.a' to make the
  3525. problem go away.
  3526.  
  3527. 11.8 Floating point exception in libm functions
  3528. ===============================================
  3529.  
  3530. **Q*: When I use the `ldexp' function, my program crashes with SIGFPE.
  3531. What's wrong?*
  3532.  
  3533. *A* : There is a bug in the scaling code in `libm.a' library released with
  3534. DJGPP v2.0 which affects several library functions such as `ldexp'.  A
  3535. work-around is to link without `-lm' switch; this will cause `GCC' to use
  3536. math functions from `libc.a'.  If you need math functions which are only in
  3537. `libm.a', or if you need `libm.a' for better numerical performance, a patched
  3538. version of libm is available, e.g.
  3539. ftp://ftp.lstm.ruhr-uni-bochum.de/pub/djgpp/libm.zip, courtesy of Tom Demmer
  3540. <Demmer@LStM.Ruhr-Uni-Bochum.De>.  DJGPP v2.01 corrects this bug, so upgrade
  3541. to that version if you can.
  3542.  
  3543. 12. Debugging DJGPP Programs
  3544. ****************************
  3545.  
  3546.   This chapter discusses the debuggers you can use with DJGPP and answers some
  3547. of the questions you might have when debugging DJGPP programs.
  3548.  
  3549. 12.1 How to run a DJGPP program under debugger
  3550. ==============================================
  3551.  
  3552. **Q*: How do I debug my programs?*
  3553.  
  3554. *A* : First, remember to use the `-g' switch when you compile and link.  This
  3555. puts debugging information into your executable.  When linking, don't use the
  3556. `-s' switch.  Here are a few examples of compilation and link command lines
  3557. when you intend to debug a program:
  3558.  
  3559.       gcc -Wall -c -g -O myfile.c
  3560.      
  3561.       gcc -Wall -O2 -g -o myprog mymain.c mysub1.c mysub2.c -lm
  3562.      
  3563.       gcc -g -o myprog myprog.o mysub.o
  3564.  
  3565. (Note that with `gcc', you can use optimization switches when compiling with
  3566. `-g.')
  3567.  
  3568. Then, to debug the program, use a command line like this (here for `gdb'):
  3569.  
  3570.       gdb myprog.exe
  3571.  
  3572. Beginning with v2.01, DJGPP debuggers can debug both unstubbed COFF images
  3573. and DOS-style .exe executables (v2.0 only supported COFF files).  To debug a
  3574. COFF file, name it without the .exe extension, like so:
  3575.  
  3576.       gdb myprog
  3577.  
  3578. You can use one of several available debuggers with DJGPP:
  3579.  
  3580.   a. `RHIDE', the DJGPP IDE by Robert Hoehne (available from the DJGPP
  3581.      archives, e.g.
  3582.      ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2apps/rhide10b.zip).  It
  3583.      includes an integrated source-level debugger based on GDB code and
  3584.      presents a user interface like that of Borland's IDE or Turbo Debugger.
  3585.  
  3586.   b. `RHGDB', a stand-alone version of GDB with a Turbo Vision user
  3587.      interface.  `RHGDB' is part of the RHIDE distribution; it only supports
  3588.      part of GDB features.
  3589.  
  3590.   c. `FSDB', the full-screen debugger, from the `djdev' distribution.  This
  3591.      presents a user interface like that of Borland's Turbo Debugger, but
  3592.      unlike TD, *it isn't a source-level debugger* (although it will show the
  3593.      source code together with the machine instructions).  It also supports
  3594.      data-write breakpoints: a powerful feature for hunting down code which
  3595.      overwrites data it shouldn't touch.  Another advantage of `FSDB' is that
  3596.      you can easily debug programs that grab the screen, because it can
  3597.      switch between the debugger screen and the application screen.  The main
  3598.      disadvantage of `FSDB' is that you cannot easily examine the contents of
  3599.      complex data structures.  Remember to prepend an underscore `_' to the
  3600.      names of C identifiers when you use them with `FSDB'; for C++ programs
  3601.      you will have to find out the mangled names of static class variables
  3602.      and methods to make `FSDB' understand them.
  3603.  
  3604.   d. The GNU Debugger, `GDB' (get the file gdb416b.zip, e.g.
  3605.      ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/gdb416b.zip.  This is
  3606.      a powerful source-level debugger, but it uses a line-oriented user
  3607.      interface.  People who are familiar with using `GDB' on Unix should know
  3608.      about the following important differences in its operation on MS-DOS:
  3609.  
  3610.         * The command-line arguments can be only passed to the debuggee from
  3611.           within the debugger (use the `set args' or `run' commands), not
  3612.           from the `GDB' command line.
  3613.  
  3614.         * You cannot rerun the debuggee when it exits.  You must exit `GDB'
  3615.           and restart it.
  3616.  
  3617.         * `GDB' is currently configured for DJGPP in a way that makes loading
  3618.           a program and reading a source file when a breakpoint is hit
  3619.           *exceedingly* slow: it can take more than a minute for a very large
  3620.           program.  Be patient and don't decide that `GDB' is wedged unless
  3621.           you've waited several minutes.  A source-level patch to GDB was
  3622.           posted to the DJGPP News group, which corrects this problem; you
  3623.           can get this patch by searching the DJGPP mail archives.
  3624.  
  3625.         * `GDB' doesn't know about PC-specific keys, so you cannot use the
  3626.           arrow keys for command history editing.  Use ASCII control keys
  3627.           instead (`^F' for forward character, `^B' for backward character,
  3628.           `^P' for previous line, `^N' for next line, etc.).
  3629.  
  3630.         * The debugger and the debuggee share their file handles.  This means
  3631.           that if your program redirects or closes its `stdin' or `stdout',
  3632.           you will be unable to communicate with `GDB.'
  3633.  
  3634.         * The initial commands are read from a file named `gdb.ini' instead
  3635.           of `.gdbinit' which isn't a legal filename under MS-DOS.
  3636.  
  3637.         * `GDB' uses the GNU `readline' package for its input.  The
  3638.           `readline' init file (`~/.inputrc' on Unix) is called `/inputrc' on
  3639.           MS-DOS and should be in the root directory of the current drive.
  3640.  
  3641.   e. `EDEBUG32' is the most basic debugger you can use with DJGPP.  One case
  3642.      when you would need to use it is when you debug a DXE module (see
  3643.      explanation of what a DXE is in Section 22.13), because `GDB' doesn't
  3644.      support debugging DXEs.
  3645.  
  3646.  
  3647. You invoke any debugger like this:
  3648.  
  3649.       <debugger-name> <program> <args...>
  3650.  
  3651. Note that the `argv[0]' parameter under the debugger is *not* the full
  3652. pathname of the debuggee, so programs which use `argv[0]' for their operation
  3653. might behave differently under a debugger.
  3654.  
  3655. 12.2 You need QEMM 7.53 or later
  3656. ================================
  3657.  
  3658. **Q*: Whenever I call any DJGPP debugger to debug my program, it crashes
  3659. immediately.*
  3660.  
  3661. *A* :  Are you running under Quarterdeck's QDPMI?  Then you should upgrade to
  3662. QEMM 7.5 patch-level #3 or later.  That patch corrects a subtle problem in
  3663. QDPMI which was triggered by DJGPP debuggers.  If you cannot or wouldn't
  3664. upgrade, for money or love, turn OFF the DPMI services of QDPMI and use
  3665. `CWSDPMI' as your DPMI host.  To disable QEMM DPMI services either uninstall
  3666. QDPMI, or go to the QEMM directory and issue the following command:
  3667.  
  3668.       qdpmi off
  3669.  
  3670. 12.3 GDB won't debug unless it sees COFF output
  3671. ===============================================
  3672.  
  3673. **Q*: I try invoking GDB on my program, but it says: "not in executable
  3674. format: File format not recognized."  Huh?*
  3675.  
  3676. *A* :  Most probably, you've invoked GDB from DJGPP v2.0 on a `.exe' program.
  3677. That version of GDB needs to be called with the name of un-stubbed COFF
  3678. executable as its argument.  To get both a `.exe' and a COFF file, you should
  3679. make your link command line look this way:
  3680.  
  3681.       gcc -o foo foo.o
  3682.  
  3683. instead of
  3684.  
  3685.       gcc -o foo.exe foo.o
  3686.  
  3687. (the latter will only produce `foo.exe', while the former produces both
  3688. `foo', the COFF executable which gdb needs, and `foo.exe').
  3689.  
  3690. To produce a COFF file from a `.exe' program, use the `EXE2COFF' program
  3691. which comes with DJGPP, like this:
  3692.  
  3693.       exe2coff foo.exe
  3694.  
  3695. Debuggers which come with DJGPP v2.01 can debug COFF and .exe programs alike,
  3696. so upgrading to v2.01 should solve this problem.
  3697.  
  3698. 12.4 Debuggers use the transfer buffer.
  3699. =======================================
  3700.  
  3701. **Q*: My program corrupts files and screen writes, and otherwise behaves
  3702. strangely when run under a debugger.*
  3703.  
  3704. *A* :  Do you use the transfer buffer to move data between your program and
  3705. conventional (under 1 MByte) memory?  Then it might be that the debugger
  3706. corrupts your I/O.  The debugger itself uses the transfer buffer for disk
  3707. read requests and screen writes.  If you single step through any of your app
  3708. routines which use the transfer buffer, the debugger might overwrite its
  3709. contents, which may alter the correct behavior.
  3710.  
  3711. To work around this, don't step with the debugger through your functions
  3712. which use the transfer buffer.
  3713.  
  3714. If all of the above doesn't make sense for you, don't worry: if you don't
  3715. know what the transfer buffer is, and you only trace into your own functions,
  3716. then you won't hit this problem.
  3717.  
  3718. 12.5 How to debug a graphics program
  3719. ====================================
  3720.  
  3721. **Q*: How can I debug a graphics program?  The debugger runs my program fine,
  3722. but when a breakpoint is hit with the screen in a graphics mode I can't read
  3723. the text printed by the debugger.*
  3724.  
  3725. *A* :  Redirect the debugger output to your printer, like this:
  3726.  
  3727.       gdb myprog > prn
  3728.  
  3729. This will only work if the program itself doesn't write to stdout (graphics
  3730. programs usually don't); otherwise the debugger output will get mixed up with
  3731. your program's output.
  3732.  
  3733. The FSDB debugger can switch between the application screen and the debugger
  3734. screen, so you might use it, at a price of working with a low-level debugger.
  3735. Press `Alt-F5' to switch between the two screens.  Stock FSDB as distributed
  3736. with DJGPP can only do this with text screens, but a modified version of FSDB
  3737. with graphics support, e.g.
  3738. ftp://ftp.delorie.com/pub/djgpp/contrib/gnudebug.zip is available that knows
  3739. about many graphics modes (it can also be found on the Oulu repository, e.g.
  3740. ftp://x2ftp.oulu.fi/pub/msdos/programming/djgpp2/gnudebug.zip).
  3741.  
  3742. Future versions of RHIDE might allow debugging graphics programs, so try to
  3743. find out whether such a version is available.
  3744.  
  3745. As yet another possibility, consider using the `MSHELL' program which will
  3746. redirect I/O from any program to the monochrome monitor at the BIOS level, so
  3747. you can use it even with GDB.  `MSHELL' was written by DJ Delorie
  3748. <dj@delorie.com> and is available as mshell10.zip, e.g.
  3749. ftp://ftp.delorie.com/pub/djgpp/ofc/mshell10.zip.  Be sure that you don't
  3750. have some other TSR installed that catches screen writes and bypasses the
  3751. BIOS functions, or else `MSHELL' won't help you.  For example, changing the
  3752. code page (with the DOS `CHCP' or `MODE' commands) might do this.
  3753.  
  3754. 12.6 GDB finds only `.cc' source
  3755. ================================
  3756.  
  3757. **Q*: When I try to debug my C++ programs, the debugger claims it can't find
  3758. the source file:*
  3759.  
  3760.       file.cc: No such file or directory.
  3761.  
  3762. *The source file *is* there, but it's called `file.cpp', not `file.cc.'  Why
  3763. does this happen?*
  3764.  
  3765. *A* :  It's a bug in GCC.  It erroneously assumes that a C++ source always
  3766. has a `.cc' extension.  Until this bug is corrected in some future version of
  3767. GCC, you're better off calling your C++ files `*.cc.'  If this is
  3768. unacceptable, then you can work around this bug by invoking `cc1plus' and the
  3769. assembler pass manually.  The bug in GCC manifests itself in that `cc1plus'
  3770. is called with the option `-dumpbase file.cc.'  If you replace this with
  3771. `-dumpbase file.cpp' (or whatever your extension is), the debugger will
  3772. happily find your sources.
  3773.  
  3774. 12.7 Can GDB print class members?
  3775. =================================
  3776.  
  3777. **Q*: It seems that GDB doesn't recognize C++ class members by their
  3778. original, unmangled names.  Do I really need to figure out the mangled names
  3779. of all my class variables and methods to be able to debug them?*
  3780.  
  3781. *A* :  No, you don't.  `GDB' *does* allow you to use the original names, it's
  3782. just that it usually treats the `::' in their names as word delimiters.
  3783. Include the name of the method or a class static variable in single quotes,
  3784. and `GDB' will recognize them as a single word.  For example, if your class
  3785. `CMPForward' has a method named `go' which you need to put a breakpoint in,
  3786. use the following command:
  3787.  
  3788.        b 'CMPForward::go'
  3789.  
  3790. Other `GDB' features that might be useful in this context are the various
  3791. demangling options, like `set print demangle', `set demangle-style' etc.;
  3792. look them up in the GDB on-line docs.
  3793.  
  3794. However, there are some cases where you won't be able to get GDB to demangle
  3795. C++ function names no matter how hard you try.  This is due to a lack of
  3796. sufficient debugging information in the COFF files with SDB debug data.
  3797. There's simply not enough info there for GDB to detect the source language
  3798. and use C++-specific support.  If you need a description of the GNU style of
  3799. mangling C++ names (so you could demangle them yourself), look in the GDB or
  3800. Libg++ source distribution, in the libiberty directory, for a file named
  3801. `cplus-demangle.c'.  If you really need full C++ support in DJGPP, you will
  3802. have to recompile GCC with stabs debugging support.  Robert Hoehne
  3803. <Robert.Hoehne@Mathematik.tu-chemnitz.de>, who did that, reports that it is
  3804. only necessary to change the configuration file `go32.h' in the GCC sources
  3805. and rebuild `cc1.exe' and `cc1plus.exe'.  Caveat emptor: `FSDB' and
  3806. `EDEBUG32' don't understand stabs, so you will have to compile with `-gcoff'
  3807. option to use these debuggers.
  3808.  
  3809. Note that, as the debugger built into RHIDE uses GDB code, it will also
  3810. sometimes have such problems with debugging C++ programs.
  3811.  
  3812. 12.8 GDB cannot list source that was #include'd
  3813. ===============================================
  3814.  
  3815. **Q*: My source file #include's another source file, but I cannot set a
  3816. breakpoint in that included code, because GDB says there is no such line, or
  3817. no such source file...*
  3818.  
  3819. **Q*: I cannot debug code produced by Flex, or Bison, or F2C, because GDB
  3820. somehow messes up all the source file and line number info!*
  3821.  
  3822. *A* :  This is a genuine limitation of the COFF format used by DJGPP.  It can
  3823. only handle a single source file for a given object file.  It does include
  3824. correct line numbers, but the name of the source file is wrong, so debugging
  3825. such files just doesn't work.
  3826.  
  3827. For source files that include other source files, you can work around this by
  3828. just inserting the included source with your editor while you debug the
  3829. program.  For code produced by other programs, like `F2C' or `Bison', you
  3830. will have to delete the `#line' directives from the generated C source, and
  3831. debug the generated code as regular C program.
  3832.  
  3833. 12.9 Debuggers choke on some programs ...
  3834. =========================================
  3835.  
  3836. **Q*: I cannot debug Emacs (or any program that requests raw keyboard input):
  3837. when I press Ctrl-C, any debugger I tried reported SIGINT.  But I cannot
  3838. operate the debugged program without Ctrl-C (in Emacs, it's necessary to exit
  3839. the editor)!*
  3840.  
  3841. **Q*: I cannot debug any program which catches signals!!??*
  3842.  
  3843. **Q*: I compiled my program with `-pg' switch, and now I cannot debug it...*
  3844.  
  3845. **Q*: When my program hits a breakpoint in GDB, the debugger reports SIGSEGV,
  3846. but only under Windows...*
  3847.  
  3848. *A* : There are currently a few limitations in debugging programs which use
  3849. interrupts or exceptions.  Programs compiled for profiling may crash under a
  3850. debugger with SIGSEGV or a GPF, with no addresses that `symify' can identify;
  3851. programs using `alarm' or `setitimer' can't be debugged, either.  You can't
  3852. hook the keyboard interrupt in a debugged program, and you can't debug a
  3853. program which uses floating point on a machine without FP hardware (unless
  3854. you use `WMEMU' as your emulator, but even WMEMU doesn't solve all the
  3855. problems).  The reason for all these problems is that any exceptions or
  3856. signals that happen when your program runs under a debugger will be caught by
  3857. the debugger instead, and they won't get passed to the debuggee.  To debug
  3858. programs which hook hardware interrupts, you will have to chain the old
  3859. real-mode interrupt handler to your new handler, which requires to write
  3860. special debug version of the program.
  3861.  
  3862. At least some of these limitations will be fixed in future versions of DJGPP.
  3863. For now, the only work-around that's available is for the case where you
  3864. need a `Ctrl-C' keypress to go to the debuggee instead of the debugger: use
  3865. the `Alt-Numeric-3' (that is, simultaneously press the `Alt' key and the `3'
  3866. key on the numeric keypad, then release the `Alt' key).  Some programs (but
  3867. not Emacs) will also treat the `Ctrl-2' keypress as `Ctrl-C'.
  3868.  
  3869. Another known problem is that `GDB' GP Faults when the program hits a
  3870. breakpoint under Windows 3.x (Windows 9x doesn't have this problem).  This is
  3871. because the breakpoint instruction causes a software interrupt (as opposed to
  3872. an exception) under Windows 3.x, and the DJGPP debug support currently only
  3873. catches debug exceptions.  The only work-around is to use the *hardware*
  3874. breakpoints (which use the special debug registers of the i386 and higher
  3875. CPUs, and which do work with DJGPP on Windows 3), and never have more than 4
  3876. of them active at the same time.  `FSDB' will automatically use the hardware
  3877. breakpoints for the first 4 breakpoints (so it works on Windows 3.x unless
  3878. you set more than 4 breakpoints simultaneously), but with `GDB', you will
  3879. have to explicitly use the `hbreak' and `thbreak' (instead of `break' and
  3880. `hbreak') commands which set hardware breakpoints.  This works with DJGPP
  3881. ports of GDB 4.16 and later.  Note that `GDB' uses the ordinary breakpoints
  3882. to implement the `step', `next' and similar commands, so you can't use these
  3883. on Windows 3.x; use the temporary hardware breakpoints instead.  The above is
  3884. also true for watchpoints (which watch for variables to change value): you
  3885. need to use hardware watchpoints with GDB (the total number of breakpoints and
  3886. watchpoints cannot exceed 4).  Same considerations apply to the debugger
  3887. built into RHIDE.
  3888.  
  3889. 13. Profiling DJGPP Programs
  3890. ****************************
  3891.  
  3892.   This chapter explains how to optimize your program for speed using the
  3893. profiler, and discusses some problems you might have with it.
  3894.  
  3895. 13.1 How to profile a DJGPP program
  3896. ===================================
  3897.  
  3898. **Q*: How can I profile my program to see where it spends most of its run
  3899. time?*
  3900.  
  3901. *A* :  DJGPP includes a profiling facility.  To use it, compile and link with
  3902. `-pg' option, run your program as you usually would, then run a program
  3903. called `gprof':
  3904.  
  3905.       gprof myprog
  3906.  
  3907. (change `myprog' to whatever name your program is).  This will print an
  3908. execution profile.
  3909.  
  3910. `Gprof' is part of GNU Binutils distribution, e.g.
  3911. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bnu27b.zip.
  3912.  
  3913. 13.2 Programs compiled with -pg crash when run
  3914. ==============================================
  3915.  
  3916. **Q*: I cannot profile my program: when I compile it with -pg, it crashes or
  3917. wedges my machine!*
  3918.  
  3919. *A* :  DJGPP v2.01 has a bug in one of its library functions which is only
  3920. linked into your program when it is compiled with the `-pg' option.  A patch
  3921. was posted to the DJGPP News group; you can find it by searching the DJGPP
  3922. mail archives.  A work-around is to run the program compiled with `-pg' on
  3923. vanilla DOS configuration (no memory managers such as EMM386 or QEMM, and no
  3924. Windows).
  3925.  
  3926. 13.3 Gprof won't work unless it can find COFF executable
  3927. ========================================================
  3928.  
  3929. **Q*: When I run `Gprof', it complains that it cannot find my program.  But
  3930. I've just run it!!*
  3931.  
  3932. **Q*: I run `Gprof' on my program, and it says: "bad format".*
  3933.  
  3934. *A* :  `Gprof' from DJGPP v2.0 needs the original COFF file the linker
  3935. produced.  If you delete it, or feed `Gprof' with the `.exe' file instead, it
  3936. will be most unhappy.  The way to produce the COFF output is explained in the
  3937. section dealing with GDB in Section 12.3, above.  Alternatively, upgrade to
  3938. DJGPP v2.01, where all Binutils programs know about .exe executables.
  3939.  
  3940. 13.4 Where is Gprof docs?
  3941. =========================
  3942.  
  3943. **Q*: What about all those `Gprof' options?  Where can I find their docs?*
  3944.  
  3945. **Q*: I can't figure out some of the info in the `Gprof' report ...*
  3946.  
  3947. *A* :  `Gprof' is only documented on a man page, `gprof.1.'  If you don't
  3948. have one, you will have to look for it in the Binutils distribution, e.g.
  3949. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bnu27b.zip.
  3950.  
  3951. 13.5 Why is `__dpmi_int' so heavily used?
  3952. =========================================
  3953.  
  3954. **Q*: I've profiled my program and found that the routine which takes 60% of
  3955. the running time is some obscure library function called `__dpmi_int.'  Can't
  3956. you guys make your library right?*
  3957.  
  3958. *A* :  Does your program use I/O or other real-mode services (like BIOS)
  3959. extensively?  All those services are invoked through a DPMI service call
  3960. which is issued by `__dpmi_int.'  So what the profile really says is that the
  3961. running time of your program is governed by time-consuming operations such as
  3962. disk I/O.
  3963.  
  3964. 13.6 `gprof' doesn't produce output
  3965. ===================================
  3966.  
  3967. **Q*: Every time I run the profiler it says "gmon.out: no such file or
  3968. directory" and no profile is produced.  What is this `gmon.out' and why won't
  3969. `gprof' compute the profile?*
  3970.  
  3971. *A* :  `gmon.out' is the file with raw execution counts and timing info that
  3972. `gprof' needs to produce the profile.  The file is written by the profiled
  3973. program when it exits.  If the file isn't created, it might be because one of
  3974. the following reasons:
  3975.  
  3976.    * You didn't compile and/or link your program with the `-pg' switch.  Note
  3977.      that *both* compilation and link need to be done with `-pg', because the
  3978.      functions that actually write the results to `gmon.out' are only linked
  3979.      in when `gcc' sees `-pg' on the link command line.
  3980.  
  3981.    * You have called `ld.exe' directly to link your program and forgot to
  3982.      mention the files and switches necessary for the profiled program
  3983.      operation.  You should use `gcc' to link your program instead of calling
  3984.      the linker directly; a `-pg' switch to `gcc' is all that it takes to
  3985.      make sure that the linker will get all the necessary arguments. (If you
  3986.      absolutely need to call `ld.exe' directly, invoke `gcc' once with a `-v'
  3987.      switch and you will see what the arguments are that you should pass to
  3988.      the linker in your case.)
  3989.  
  3990.    * Your program exited abnormally.  The function which generates `gmon.out'
  3991.      is registered with the `atexit' library function, and won't be called if
  3992.      the program was terminated in an abnormal way.  Make sure that your
  3993.      program exits with a call to `exit' library function or with a `return'
  3994.      statement in your `main' function.  For example, if your program dies
  3995.      with an exception or a signal, install a signal handler and make it call
  3996.      `exit.'
  3997.  
  3998. 14. Run-time Performance of DJGPP Programs
  3999. ******************************************
  4000.  
  4001.   This chapter deals with issues pertinent to run-time performance of DJGPP
  4002. programs.
  4003.  
  4004. 14.1 How efficient is DJGPP-generated code?
  4005. ===========================================
  4006.  
  4007. **Q*: How does DJGPP compare with other DOS-based C compilers in terms of
  4008. efficiency of generated code?*
  4009.  
  4010. **Q*: Won't my program run *much* slower when compiled by DJGPP, due to all
  4011. those CPU cycles wasted in switches between protected and real mode?*
  4012.  
  4013. *A* :  The quality of code generated by GCC with optimization turned on
  4014. (`-O2' switch to the compiler) is generally at least as good as what you will
  4015. get from top commercial products, like Borland, Microsoft and Watcom.  Mode
  4016. switches indeed have a certain performance hit, but in most programs it is
  4017. negligibly small, because only DOS and BIOS services require such a switch,
  4018. and most programs spend most of their time doing other things.
  4019.  
  4020. 14.2 Comparing v2 with DJGPP v1.x
  4021. =================================
  4022.  
  4023. **Q*: I switched to v2 and my programs now run slower than when compiled with
  4024. v1.x...*
  4025.  
  4026. **Q*: I timed a test program and it seems that DJGPP v2.01 produces slower
  4027. executables than v2.0, which in turn was slower than v1.x.  Why are we giving
  4028. up so much speed as we get newer versions?*
  4029.  
  4030. *A* :  In general, GCC 2.7.2 which comes with DJGPP v2.0 generates tighter,
  4031. faster code, than GCC 2.6.3 which came with v1.x.  But it sometimes produces
  4032. buggy code when "strength reduction" optimizations are enabled.  So DJGPP
  4033. v2.0 by default disables this kind of optimization, which might sometimes
  4034. yield slower code.  If you need extra speed, first debug your program with
  4035. default optimization options, and then recompile with `-fstrength-reduce'
  4036. switch to see if that makes any difference; or upgrade to DJGPP v2.01 where
  4037. GCC doesn't have this bug.
  4038.  
  4039. Comparison between GCC 2.7.2 (in v2.0) and 2.7.2.1 (in v2.01) shows that
  4040. 2.7.2.1 optimizes just as well as 2.7.2, but it takes a different combination
  4041. of the optimization-related options to achieve the greatest speed in each
  4042. compiler version.  The default optimization options has also changed; for
  4043. example, `--force-mem' is switched on by `-O2' in 2.7.2.1; it wasn't before.
  4044. GCC offers a plethora of optimization options which might make your code
  4045. faster or slower (see the GCC docs for a complete list); the best way to find
  4046. the correct combination for a given program is to profile and experiment.
  4047. Elliott Oti <e.oti@stud.warande.ruu.nl> suggests the following tips:
  4048.  
  4049.    * Compile your code with the ordinary compilation switches `-O2 -m486
  4050.      -fomit-frame-pointer -ffast-math'.
  4051.  
  4052.    * Profile your code and check which functions are "hot spots".
  4053.      Disassemble them, or compile with `-S', and examine the machine code.
  4054.  
  4055.    * If the disassenbly shows there aren't too many memory accesses inside
  4056.      the inner loops, try adding `-fforce-addr' option; it helps a lot if a
  4057.      couple of pointers are used heavily within a single loop.  If there are
  4058.      a lot of memory references, try adding `-fno-force-mem', to prevent GCC
  4059.      from repeatedly copying variables from memory into registers.
  4060.  
  4061.    * Try adding `-funroll-loops' and `-funroll-all-loops' and profile the
  4062.      effect.
  4063.  
  4064.    * If different time-critical functions exhibit different behavior under
  4065.      some of the optimization options, try compiling them with the best
  4066.      combination for each one of them.
  4067.  
  4068. 14.3 DJGPP programs on a Pentium
  4069. ================================
  4070.  
  4071. **Q*: Does DJGPP support Pentium-specific optimizations?*
  4072.  
  4073. **Q*: I run the same program on a 486 and on a Pentium, and it's slower on a
  4074. Pentium!!*
  4075.  
  4076. *A* : DJGPP doesn't add to, or otherwise change the compiler features offered
  4077. by GCC.  DJGPP is just a port of GCC to MSDOS.  Since GCC (as of version
  4078. 2.7.2.1) doesn't support Pentium-specific optimizations, neither does DJGPP.
  4079.  
  4080. A program might sometimes run slower on a Pentium due to alignment problems
  4081. in DJGPP.  GCC makes assumptions about how GAS (the assembler) handles
  4082. alignment, but when GAS is built with the default DJGPP configuration, it
  4083. treats alignment in a way that's different from what GCC assumes.  The
  4084. outcome of this is that longs are word-aligned, doubles are dword-aligned,
  4085. etc.  Depending on the DJGPP version, link order, library differences, you
  4086. might get lucky (or unlucky) with a 50/50 chance to get an improper
  4087. alignment.  Different CPUs have different penalties for unaligned accesses,
  4088. which may explain differences in speed.
  4089.  
  4090. You might consider adding some slack static variables to induce changes in
  4091. alignment; if any of the changes suddenly cause a significant change in the
  4092. runtime performance, then alignment might be the reason.
  4093.  
  4094. 14.4 My program's I/O is so slow!
  4095. =================================
  4096.  
  4097. **Q*: I measured the time required to read a 2 MByte file in DJGPP and in
  4098. Borland C.  It took the DJGPP program 2.5 seconds to do it, while Borland did
  4099. it in just under 2.  Isn't that *horribly* slow performance??*
  4100.  
  4101. **Q*: I tried to improve DJGPP I/O throughput by defining a 64KB-large buffer
  4102. for buffered I/O with a call to `setvbuf', but that had no effect.  Why is
  4103. that?*
  4104.  
  4105. *A* :  Doing I/O from protected-mode programs requires that low-level library
  4106. functions move the data between the extended memory and low memory under the
  4107. 1 MByte mark, where real-mode DOS can get at it.  That area in the low memory
  4108. is called the "transfer buffer".  This data shuffling means that some I/O
  4109. speed degradation is inevitable in any protected-mode program which runs
  4110. under DOS (including, for example, Windows programs when Windows is set to
  4111. 386-Enhanced mode).  By default, DJGPP moves data in chunks of 16 KB, so
  4112. defining a buffer larger than that won't gain anything.  The size of transfer
  4113. buffer is customizable up to a maximum of 64 KB, so if your program really
  4114. reads a lot of large files, you might be better off enlarging it (with the
  4115. `STUBEDIT' program).
  4116.  
  4117. Some programs which only copy data between two files might gain significantly
  4118. if you write your custom low-level I/O functions that avoid moving data to
  4119. extended memory (only to move them back to the transfer buffer).  However,
  4120. these cases are rare.
  4121.  
  4122. That said, I would like to point out that waiting another 0.5sec for reading
  4123. a 2 MByte file isn't that bad: it is indeed about 25% longer than you can do
  4124. under DOS, but it's only half a second...  Besides, most programs read and
  4125. write files which are only a few hundreds of kilobytes, and those will suffer
  4126. only a negligible slow-down.
  4127.  
  4128. 14.5 My ported program runs much slower!
  4129. ========================================
  4130.  
  4131. **Q*: How come my program, which I ported from Borland/MS C and which doesn't
  4132. use much I/O, still runs much slower under DJGPP? *
  4133.  
  4134. *A* :  Explore the following possible causes for this:
  4135.  
  4136.   a. Your program extensively calls services other than I/O which require mode
  4137.      switch (like BIOS Int 10h, mouse services, etc.).
  4138.  
  4139.      You can tell how much your program switches to real mode by profiling
  4140.      your program.  In the profile, look at the proportion of time your
  4141.      program spends in low-level library functions called `__dpmi_int' (which
  4142.      calls real-mode DOS/BIOS services) and `__dj_movedata' (which moves data
  4143.      between the transfer buffer and your program).  If this proportion is
  4144.      large, try rewriting your program to minimize use of those functions
  4145.      which require a mode switch, even at a price of more computation (a mode
  4146.      switch usually eats up hundreds of CPU cycles).
  4147.  
  4148.   b. Your program uses library functions/classes which are implemented less
  4149.      efficiently by GCC.  Or you might be a heavy user of functions which
  4150.      other compilers convert to inline code, while GCC doesn't inline most
  4151.      library functions.  If this is the case, you will see those functions as
  4152.      "hot spots" on the program histogram produced by the `Gprof' profiler.
  4153.      If you find this to be the problem, write your own, optimized versions of
  4154.      those functions.  It's best to write them as inline assembly functions,
  4155.      for maximum performance.  If you find library functions which are
  4156.      inefficient, please inform the DJGPP news group by posting to the
  4157.      comp.os.msdos.djgpp news group, so this could be fixed by people who
  4158.      maintain the library.
  4159.  
  4160.   c. If your program spends most of its time in a certain innermost loop, you
  4161.      should try enabling some of the optimization options which aren't
  4162.      enabled by default.
  4163.  
  4164.  
  4165. 15. Run-Time Memory Issues
  4166. **************************
  4167.  
  4168.   This chapter answers questions which are related to DJGPP run-time memory
  4169. allocation.
  4170.  
  4171. 15.1 How much virtual memory do you have?
  4172. =========================================
  4173.  
  4174. **Q*: How much virtual memory can I use in DJGPP programs?*
  4175.  
  4176. *A* :  That depends on the DPMI host you are using.  CWSDPMI (the free DPMI
  4177. host which comes with DJGPP) will let you use all available conventional and
  4178. extended memory (up to 128M) and up to 128M of disk space, for a grand total
  4179. of 256M of virtual memory for your application.  Try a `malloc(50*1024*1024)'
  4180. some day.
  4181.  
  4182. With other DPMI hosts, your mileage may vary.  Quarterdeck's QDPMI, for
  4183. instance, has a bug in some of its versions which effectively disables
  4184. virtual memory under DJGPP (described in QDPMI VM bug in Section 15.3,
  4185. below), so you only have whatever free physical RAM is left.  Under Windows
  4186. 3.x, the amount of virtual memory you get depends on various virtual memory
  4187. settings in the Control Panel and on the `.pif' file settings for the program
  4188. you run (see Windows allocation subtleties in Section 15.5, below).  Under
  4189. Windows 9x, the memory settings of the DOS Applications' Property Sheet
  4190. define how much virtual memory a DJGPP program will get (see Win9x allocation
  4191. details in Section 15.6, below).
  4192.  
  4193. 15.2 It seems `malloc'/`free' don't affect virtual memory...
  4194. ============================================================
  4195.  
  4196. **Q*: I did `malloc(50*1024*1024)', but didn't see any paging happen, and I
  4197. only have 8 MBytes of RAM on my machine.  Is this virtual memory thing for
  4198. real?*
  4199.  
  4200. **Q*: I `malloc''ed a large chunk of memory, but when I check values returned
  4201. by `_go32_remaining_physical_memory' or `__dpmi_get_memory_information', I
  4202. don't see any change...*
  4203.  
  4204. **Q*: When I `free' allocated RAM, `_go32_remaining_physical_memory' reports
  4205. there was no change in the available RAM.*
  4206.  
  4207. *A* :  CWSDPMI (and, possibly, other DPMI hosts) only pages in memory when it
  4208. is actually accessed.  If you only `malloc' it, but don't actually access it,
  4209. it won't grab those pages.  Try `calloc' and see the *big* difference.
  4210.  
  4211. When you call `free', DJGPP library doesn't return memory to the system, it
  4212. just adds it to its internal pool of free pages.  So, from the system point
  4213. of view, these pages are not "free".
  4214.  
  4215. 15.3 Failure to get more memory than is physically installed
  4216. ============================================================
  4217.  
  4218. **Q*: When I try to access more memory than the free physical RAM, `malloc'
  4219. returns a `NULL' pointer, or I get some cryptic error message like this:*
  4220.  
  4221.      DPMI: Not enough memory (0x00860000 bytes)
  4222.  
  4223. *or like this:*
  4224.  
  4225.      QDPMI: Memory Paging Violation: Illegal Page Reference [PTE=0000-0000h]
  4226.             [CR2=8006-3000h at 00E7h:0000-4936h]
  4227.      
  4228.      QDPMI: Unrecoverable Exception: 000Eh at 00E7h:0000-4936h.  Error Code = 0006h
  4229.  
  4230. *A* :  This is typical of Quarterdeck's DPMI host called QDPMI which comes
  4231. with QEMM386 version 7.53 and earlier.  Some versions of QDPMI (those which
  4232. come with QEMM v6.x) fail to resize memory blocks when the new size is more
  4233. than the available physical RAM, even though virtual memory services are
  4234. enabled; other versions (those which come with QEMM v7.x) just don't let you
  4235. allocate more memory than is physically available.  If you must use more RAM
  4236. than is physically available, disable or uninstall QDPMI in Section 12.2, and
  4237. use CWSDPMI instead.
  4238.  
  4239. This bug was corrected in QDPMI version 1.10 or later, distributed with QEMM
  4240. beginning with version 8.0, so upgrading to the latest version of QEMM might
  4241. also be a solution.  With QEMM 6.x, make sure your programs don't override
  4242. the default type of `sbrk' behavior by setting `_crt0_startup_flags' to
  4243. `_CRT0_FLAG_UNIX_SBRK' (QEMM 8.0 and later can allocate virtual memory with
  4244. both types of `sbrk' algorithm).
  4245.  
  4246. If you use another DPMI host, make sure that virtual memory is enabled.
  4247. E.g., for 386Max, include the `swapfile=' parameter to establish a virtual
  4248. memory swap file; you can make it permanent (this will speed up DJGPP
  4249. start-up) with the `/p' option.
  4250.  
  4251. 15.4 Memory allocation fails before all memory is used
  4252. ======================================================
  4253.  
  4254. **Q*: OK, I've changed my program to never allocate more memory than is
  4255. physically available, to work around that QDPMI VM bug in Section 15.3, but
  4256. my program still gets a `NULL' pointer from `malloc/calloc'!*
  4257.  
  4258. **Q*: Why is my program dying with SIGSEGV under CWSDPMI when allocating a
  4259. chunk of memory?*
  4260.  
  4261. *A* :  Another peculiarity of QDPMI which came with QEMM before version 8.0:
  4262. it will never let you allocate a chunk which is larger than half of what's
  4263. available.  The Windows 3.x behaves in the same way, and several people
  4264. reported the same to be true under Windows 95.
  4265.  
  4266. With some DPMI providers, this behavior might be triggered by a small
  4267. overhead of each `malloc' call: you might ask for half of available memory,
  4268. but the DJGPP implementation of `malloc' adds the overhead and then rounds
  4269. the amount of memory to the next power of 2 before calling `sbrk'; thus
  4270. `malloc(8MB)' will actually request 16MBytes from the DPMI host.  When in
  4271. doubt, call `sbrk' directly, especially if you don't plan to free that memory
  4272. during execution.
  4273.  
  4274. If your program asks for memory in lots of small allocations, then it might
  4275. crash when you use CWSDPMI as your DPMI host.  This is because CWSDPMI runs
  4276. out of its tables where it tracks memory allocations.  If you use release 1
  4277. of CWSDPMI, you can enlarge the maximum space that CWSDPMI uses if you get a
  4278. CWSDPMI heap-fix patch, e.g.
  4279. ftp://ftp.neosoft.com/pub/users/s/sandmann/csdpmi1heapfix.zip.  Beginning
  4280. with release 2, CWSDPMI defines a larger (6KB) default heap that is
  4281. configurable by CWSPARAM program to be anywhere between 3K and 40K bytes,
  4282. without recompiling CWSDPMI.  You should upgrade to the latest CWSDPMI if you
  4283. experience such problems.
  4284.  
  4285. 15.5 Memory allocation fails under Windows
  4286. ==========================================
  4287.  
  4288. **Q*: I'm running under Windows 3.x DOS box, but DJGPP complains about there
  4289. not being enough DPMI memory, although virtual memory is enabled.*
  4290.  
  4291. *A* :  You must make sure the size of your Windows swap file can be at least
  4292. 2 times the largest virtual memory size you need.  Check if you have enough
  4293. free disk space; if you do, run a defragger (Windows needs the swap file to
  4294. be contiguous).  This size is normally limited by the the "virtual = 4 times
  4295. free physical" rule, but you can change that by inserting the line
  4296.  
  4297.       PageOverCommit=n
  4298.  
  4299. in the `[386Enh]' section of your `SYSTEM.INI' file.  The parameter `n' is 4
  4300. by default, but can be set to be as large as 20.
  4301.  
  4302. 15.6 Memory allocation peculiarities under Windows 9x
  4303. =====================================================
  4304.  
  4305. **Q*: I seem to be unable to get more than 16 MBytes of virtual memory under
  4306. Windows 95, even though I have 32 MBytes of RAM installed on my machine, and
  4307. a lot of disk space...*
  4308.  
  4309. *A* :  You must set the maximum amount of DPMI memory to 65535K in the DOS
  4310. applications' property sheet.  If you leave that setting at the default
  4311. "Auto", you only get 16 MBytes.  You must actually type 65535 inside the
  4312. dialog box, as checking out the values from the list Windows offers will
  4313. never get you past 16384 (i.e., 16MB).
  4314.  
  4315. Note that you cannot allocate more than half the available memory in one
  4316. chunk under Windows 9x, exactly as the things are under Win3.x, and you
  4317. cannot have more than 64 MBytes of virtual memory available to DJGPP programs
  4318. running on Windows.
  4319.  
  4320. 15.7 Memory allocation fails under EMM386 or HIMEM
  4321. ==================================================
  4322.  
  4323. **Q*: My machine has 48 MBytes of RAM, but when I run DJGPP programs, they
  4324. start paging after 32 MBytes have been used...*
  4325.  
  4326. **Q*: I have 5 MBytes of free RAM on my machine, but DJGPP programs start
  4327. paging after only 256KBytes of memory were used??*
  4328.  
  4329. *A* :  This might be caused by some old versions of the memory manager
  4330. installed in your machine (like HIMEM or EMM386 from an old version of DOS),
  4331. which were limited to 32 MBytes of expanded memory.  Try running without them
  4332. (CWSDPMI can use raw extended memory), or upgrade to a newer version of DOS.
  4333.  
  4334. If your programs start paging after only 256KBytes of memory were used, most
  4335. probably you are using EMM386 and CWSDPMI, and your `CONFIG.SYS' specifies no
  4336. amount of memory when it installs EMM386.  EMM386 defaults to 256K in this
  4337. case; you should tell EMM386 explicitly how much memory it should take over.
  4338. You can use the `go32-v2' program to see what amount of extended memory your
  4339. DJGPP programs will get.
  4340.  
  4341. 15.8 How much memory do parent DJGPP programs leave for their child?
  4342. ====================================================================
  4343.  
  4344. **Q*: How much memory is available when I call the `system' library function?*
  4345.  
  4346. *A* :  In the conventional (below 640K mark) memory, you are left with
  4347. everything which was free before your program started, except what the DPMI
  4348. host uses.  The amount of conventional memory required by the DPMI host
  4349. depends heavily on the host you use.  For the first DJGPP program, QDPMI uses
  4350. about 97K, CWSDPMI uses about 70K, Windows 3.x only 18 KBytes.  Each
  4351. subsidiary call to `system' (like in recursive invocation of `Make') eats up
  4352. about 18K (16K for the transfer buffer and 2K for the PSP and environment)
  4353. for most DPMI servers; a notable exception is QDPMI which needs 97K bytes of
  4354. low memory for the subsequent calls too.  If you change the size of the
  4355. transfer buffer (with `STUBEDIT'), the amount of free conventional RAM will
  4356. change accordingly.
  4357.  
  4358. Extended memory management is left to the DPMI server; DJGPP does nothing
  4359. special about XMS when `system' is called.  This means that all the extended
  4360. memory used by the parent program is *not* freed when the child program
  4361. starts; if the child requests more memory than is physically free, the DPMI
  4362. server is expected to page some of the parent out to honor the request.
  4363. (This is unlike DJGPP v1.x, where the `go32' extender would completely page
  4364. out the parent before starting the child.)  The advantage of this is that
  4365. spawning a child or shelling out is much faster in v2 than it used to be with
  4366. v1.x, except on machines with low amounts of installed RAM.  A disadvantage
  4367. is that if you spawn a real-mode program that uses XMS, the extended memory
  4368. used up by your DJGPP program will be unavailable to it, unless you use a
  4369. memory manager (as opposed to when CWSDPMI uses raw XMS or HIMEM).  The only
  4370. way around this problem is to buy more RAM, or to install a real memory
  4371. manager.
  4372.  
  4373. Note that if you use a memory manager such as EMM386 or QEMM386 with the
  4374. NOEMS parameter, CWSDPMI will use the XMS (as opposed to VCPI) services to
  4375. allocate extended memory, and will allocate all of the available XMS memory
  4376. for itself.  So if, while your DJGPP program runs, some resident software
  4377. such as device driver or TSR will try to allocate XMS, the allocation will
  4378. fail.
  4379.  
  4380. 15.9 How much stack can I have in DJGPP programs?
  4381. =================================================
  4382.  
  4383. **Q*: My program bombs when I use very large automatic arrays.*
  4384.  
  4385. **Q*: How much stack space do I have in my program?*
  4386.  
  4387. **Q*: My program seems to overflow the stack, but only when I run it under a
  4388. debugger...*
  4389.  
  4390. **Q*: My program crashes with SIGSEGV, but the traceback makes no sense: it
  4391. points to something called ___djgpp_exception_table...  When I try to debug
  4392. this, the traceback mysteriously changes to some innocent library function,
  4393. like getc().  The same program works flawlessly when compiled with DJGPP v1.x
  4394. What is going on??*
  4395.  
  4396. *A* : DJGPP v2 programs get fixed-size stack which is allocated by the
  4397. startup code and then stays fixed for the entire lifetime of the program;
  4398. this is a bug/feature of the DPMI 0.9 specification.  By default, you have a
  4399. 256KB-long stack, but some programs which use large automatic arrays, or are
  4400. deeply recursive, might need more.  If the default stack size is not enough,
  4401. you can change it with the `STUBEDIT' program (change the parameter "Minimum
  4402. amount of stack space"), or by setting the global variable `_stklen' in your
  4403. program.  Example:
  4404.  
  4405.       unsigned _stklen = 1048576;  /* need a 1MB stack */
  4406.  
  4407. The DJGPP startup code checks both the value in the stub info and the value
  4408. of `_stklen', and uses the larger of these two.  Therefore, programs that are
  4409. known to require large stack size should set `_stklen' to make sure they will
  4410. always work, even if somebody stub-edits them to a lower value.  This
  4411. technique is also safer when you need to debug your program with `gdb' (see
  4412. below).  However, you might need to use `STUBEDIT' with programs for which
  4413. you don't have the sources.
  4414.  
  4415. Programs which need an unusually large stack might crash with bogus stack
  4416. traces, because part of the heap gets overwritten by the overflowing stack.
  4417. To see if that is the cause of such crashes, run `STUBEDIT' on your program
  4418. and crank up the stack size to a large value (like 4MBytes).  If that makes
  4419. the problem go away, tune the stack limit to the minimum value your program
  4420. can live with, then set `_stklen' to an appropriate value as explained above
  4421. and recompile the program.  (Some DPMI hosts will actually allocate the
  4422. entire stack, even if not all of it is used, so leaving it at unnecessarily
  4423. large value will hurt the program on low-memory machines.)
  4424.  
  4425. Some users have reported that they needed to enlarge the stack size of the
  4426. C++ compiler, `cc1plus.exe', to prevent it from crashing when compiling some
  4427. exceedingly large and complex C++ programs.  Another program that was
  4428. reported to need a stack larger than the default is `bccbgi.exe' from the
  4429. `BCC2GRX' package.
  4430.  
  4431. After you've used `STUBEDIT' to change the stack size, run it again to make
  4432. sure it displays as default the value you thought you entered.  This is
  4433. because `STUBEDIT' will sometimes silently set the stack size to 0 (and then
  4434. you will get the default 256K stack) if it doesn't like the value you type
  4435. (e.g. if it has a wrong syntax).
  4436.  
  4437. When you run a program as an un-stubbed COFF image under a debugger, the
  4438. stack size comes from the debugger.  So if your program needs a large stack
  4439. and you run it under `gdb', be sure to stubedit `gdb' to enlarge its stack to
  4440. at least the value your program needs to run safely.
  4441.  
  4442. Under Windows, be sure you've allocated a sufficiently large swap file (let's
  4443. say, 40MBytes) from the Windows' Control Panel, and make sure the `.PIF' file
  4444. for your program doesn't have too low limit on EMS/XMS usage (better make
  4445. them both -1).  What's that?  You don't have a `.PIF' file for this program?
  4446. Then Windows uses the default file `DOSPRMPT.PIF', which almost surely
  4447. defines very low limits on these two, and your program might have problems
  4448. getting the memory it needs for its stack.
  4449.  
  4450. DJGPP v2.0 has a subtle bug in its startup code that is seen very rarely, and
  4451. that manifests itself by a program crashing with Page Fault or SIGSEGV.  If
  4452. you are using v2.0 and enlarging the stack and the CWSDPMI heap size didn't
  4453. help, try adding some (e.g., 4KB) static data to your program and see if that
  4454. helps.  But the best way to overcome this is to upgrade to DJGPP v2.01 or
  4455. later.
  4456.  
  4457. 16. Command-line Arguments Handling in DJGPP
  4458. ********************************************
  4459.  
  4460.   DJGPP handles command-line arguments differently from most DOS-based
  4461. compilers, to make it closer to Unix platforms (so that porting of Unix
  4462. programs will be easier).  This chapter answers some questions about this
  4463. aspect of DJGPP.
  4464.  
  4465. 16.1 Filename wildcards expansion under DJGPP
  4466. =============================================
  4467.  
  4468. **Q*: Can I do filename globbing with DJGPP?*
  4469.  
  4470. **Q*: I call my program with an argument `x*y' and it complains about
  4471. something called `xyzzy'??...*
  4472.  
  4473. *A* :  The filename globbing in DJGPP is done by the start-up code, before
  4474. your `main' function is called.  Unlike other DOS-based compilers, where you
  4475. must link your program with a special object module if you want the program
  4476. to get expanded filenames, in DJGPP this is considered normal behavior and
  4477. performed by default on behalf of every DJGPP program.  The `x*y' above was
  4478. expanded to a file called `xyzzy' which was probably present in the current
  4479. working directory.  (If you don't want the default expansion, see how to
  4480. disable globbing in Section 16.2.)
  4481.  
  4482. In DJGPP, filename globbing works like in Unix, which is more general than
  4483. the usual DOS wildcard expansion.  It understands the following constructs
  4484. with special meta-characters:
  4485.  
  4486. `?'
  4487.      any single character.
  4488.  
  4489. `*'
  4490.      zero or more arbitrary characters, including a dot `.'
  4491.  
  4492. `[aA_]'
  4493.      any one of characters `a', `A', or `_'.
  4494.  
  4495. `[a-d]'
  4496.      any one of characters `a', `b', `c', or `d'.
  4497.  
  4498. `[!a-z]'
  4499.      anything *but* a lowercase letter.
  4500.  
  4501. `...'
  4502.      all the subdirectories, recursively (VMS aficionados, rejoice!).
  4503.  
  4504. `.../*'
  4505.      all the files in all subdirectories, recursively.
  4506.  
  4507. Unlike DOS, the `*' and `?' meta-characters can appear *anywhere* in the
  4508. filename pattern, like in `[a-z]*[0-9].*pp.' You can also use `*' instead of
  4509. directories, like in `*/*/*.c', but *not* on drive letters (e.g., `[a-c]:/'
  4510. won't work).
  4511.  
  4512. Note that `*.*' only picks up files that actually have an extension.  This is
  4513. contrary to the usual DOS practice where it means *all* the files, with or
  4514. without extension.
  4515.  
  4516. An argument which cannot be expanded (no filenames matching that particular
  4517. pattern) will be passed to the program verbatim.  This is different from what
  4518. you might see under Unix, where some shells (like `csh') would say something
  4519. like "No match" and won't call your program at all.  DJGPP's behavior in this
  4520. case is like shells of the Bourne legacy (`sh', `ksh', and `bash').
  4521.  
  4522. 16.2 How to disable filename wildcards expansion
  4523. ================================================
  4524.  
  4525. **Q*: OK, but I don't want my program to glob its arguments (they aren't
  4526. files at all, but they include characters like `*' and `?').  What should I
  4527. do?*
  4528.  
  4529. *A* :  You have these alternatives:
  4530.  
  4531.    * Surround your arguments with single or double quotes (this is what you
  4532.      would do under a Unix shell).
  4533.  
  4534.    * Disable globbing for your program by linking it with your custom version
  4535.      of the function with the special name `__crt0_glob_function' and make it
  4536.      always return a `NULL' pointer.  See the documentation of this function
  4537.      in the library reference.
  4538.  
  4539. 16.3 How to pass command-line arguments with quotes or <@>
  4540. ==========================================================
  4541.  
  4542. **Q*: I have a file with a single quote in its name, but the quote seems to
  4543. be stripped away when I pass it to my program ...*
  4544.  
  4545. **Q*: How do I pass a command-line argument which contains double quotes? *
  4546.  
  4547. **Q*: How do I pass an argument which begins with the <@> character?*
  4548.  
  4549. *A* :  These special characters on the command-line arguments are handled by
  4550. the filename expansion ("globbing") code before they are passed to the `main'
  4551. function (see description of filename expansion in Section 16.1), and the
  4552. quote characters serve to protect the arguments from expansion.  You should
  4553. escape-protect the quote characters with a backslash in order for them to be
  4554. treated as literal characters.  For example, if you have a file called
  4555. `myfile.c'v', type it as `myfile.c\'v' when you call your program.  If you
  4556. have single quotes in your program arguments *and* you don't want those
  4557. arguments to be expanded, then surround them by double quotes, like this:
  4558. `"*.c'v".'  The program will get the string `*.c'v' with the double quotes
  4559. stripped away.
  4560.  
  4561. Note that backslashes are only special if they are in front of a quote,
  4562. whitespace, or backslash (they also serve as DOS directory separators,
  4563. remember?).  This is also different from what you get under a Unix shell.
  4564.  
  4565. The <@> character serves to signal a "response file" (see the description of
  4566. response file method in Long commands), so it's also special.  To pass an
  4567. argument whose first character is <@>, surround that argument with single or
  4568. double quotes, otherwise it will be taken as a name of a response file which
  4569. holds the actual command line.
  4570.  
  4571. 16.4 How to pass command lines longer than 126 characters
  4572. =========================================================
  4573.  
  4574. **Q*: Can I invoke my program with a command line longer than the infamous
  4575. DOS 126-character limit?*
  4576.  
  4577. **Q*: I have a Makefile of Unix origin which contains some *very* long
  4578. command lines.  Will it work with DJGPP?*
  4579.  
  4580. *A* :  Yes and yes.  DJGPP supports several methods of passing command-line
  4581. arguments which allow it to work around the DOS 126-character limit.  These
  4582. are:
  4583.  
  4584.    * The `!proxy' method.  If you invoke the program from within another
  4585.      DJGPP program (like Make or Gcc compilation driver), it gets the address
  4586.      of the memory block where the actual command line is stored.  The
  4587.      start-up code will detect this and use that info to retrieve the
  4588.      command-line arguments.
  4589.  
  4590.      This method is suitable only for invoking DJGPP programs from other DJGPP
  4591.      programs.  You don't have to do anything special to use this method, it
  4592.      is all done automagically for you by the library functions like
  4593.      `system', `spawnXX' and `execXX' on the parent program side, and by the
  4594.      start-up code on the child side.  (In case you wonder, the name `!proxy'
  4595.      comes from the the string which identifies the use of this method:
  4596.      instead of getting the actual command line, the program gets `!proxy'
  4597.      followed by the address of the actual command line.)
  4598.  
  4599.    * The environment method.  This is the same as the `!proxy' method above,
  4600.      but the information about the long command line is stored in an
  4601.      environment variable called " !proxy" (with the leading blank and in
  4602.      lower-case).  The reason for two similar, but different methods is that
  4603.      command-line arguments passed by `system' library functions should be
  4604.      globbed by the child, while the arguments passed by `spawnXX' and
  4605.      `execXX' family of functions should not; thus the former uses the
  4606.      environment method while the latter use the `!proxy' method.
  4607.  
  4608.    * The response file method.  Any argument which starts with a <@>
  4609.      character (like in `myprog @file') will cause the named `file' to be
  4610.      read and its contents used as command-line arguments, like in many
  4611.      DOS-based compilers and linkers.  If you invoke your DJGPP program from
  4612.      the DOS command line, this would be the only method available for you to
  4613.      pass long command lines (like when calling `Gawk' or `Sed' without `-f'
  4614.      option).
  4615.  
  4616.      Note that this method makes <@> special when it is the first (or the
  4617.      only) character of a command-line argument, which should be
  4618.      escape-protected if you want to use it verbatim (see how to pass the @
  4619.      character in Section 16.3).
  4620.  
  4621. Of course, if the start-up code doesn't see any of the above methods, it will
  4622. use the command line by default.
  4623.  
  4624. 16.5 What is the maximum length of command line under DJGPP
  4625. ===========================================================
  4626.  
  4627. **Q*: What is the longest command line I can pass to gcc when it is invoked
  4628. by `Make'?*
  4629.  
  4630. *A* :  The arguments are passed to DOS Exec call (Int 21h function 4Bh) via
  4631. the transfer buffer which is 16KB-long.  Apart of the command line, it is
  4632. also used to pass other info, such as the `!proxy' parameters and the copy of
  4633. the environment for the child program (let's say, less than 2000 bytes in
  4634. most cases, but your mileage may vary).  This leaves at least 13K bytes for
  4635. arguments (including a separating blank between any two arguments).  So
  4636. unless your arguments span more than 160 screen lines, you shouldn't worry.
  4637. However, if your environment is *very* large (some people need as much as 6KB
  4638. to accommodate for all the variables used by the various packages installed
  4639. on their machine), be sure to stub-edit the programs that spawn other
  4640. programs to larger transfer buffer, or else they could fail.
  4641.  
  4642. The above limit depends on the size of the transfer buffer, so check the size
  4643. of the value recorded in the stub header of the *parent program* before you
  4644. pass extremely long command lines to its children.  GCC is the first program
  4645. you should worry about, because the linker (`ld.exe') usually gets long
  4646. command lines from GCC (they include the list of all the object files and
  4647. libraries to be linked).
  4648.  
  4649. 16.6 Why Make passes only 126 characters to programs?
  4650. =====================================================
  4651.  
  4652. **Q*: I use Make to compile with GCC, but GCC gets only the first 126
  4653. characters of its command line.  Didn't you just explain in so many words
  4654. that invoking a DJGPP program (GCC) from another DJGPP program (Make) can
  4655. safely pass up to 13K characters of command-line arguments using the `!proxy'
  4656. method?*
  4657.  
  4658. *A* :  If you use Make 3.73, check your Makefile for `SHELL = command.com'
  4659. statements, or for commands which include pipe or redirection characters like
  4660. `>', `|', etc.  If Make sees any such statements, it will invoke
  4661. `COMMAND.COM' to run GCC, and `COMMAND.COM' can't pass more than 126
  4662. characters to GCC.  To work around, comment-out the `SHELL=' line, and change
  4663. your commands to work without redirection/pipe characters.  One easy way to
  4664. get rid of redirection characters without losing their effect is to use the
  4665. `redir' program which comes with DJGPP.  For example, the following command:
  4666.  
  4667.        frobnicate foo.bar > myfile.tmp
  4668.  
  4669. can be re-written instead like this:
  4670.  
  4671.        redir -o myfile.tmp frobnicate foo.bar
  4672.  
  4673. The port of Make 3.75 which comes with DJGPP v2.01 doesn't call `COMMAND.COM'
  4674. in the above cases, but rather emulates pipes and redirection internally, so
  4675. upgrading to v2.01 will solve such problems.  If you think about using Make
  4676. 3.75 with DJGPP v2.0, don't: invoking v2.0 programs from v2.01 programs will
  4677. cause subtle and hard-to-debug problems due to incompatibilities between
  4678. these two versions regarding the methods of invoking child programs (in
  4679. particular, v2.0 doesn't support the environment method of passing long
  4680. command lines described above).
  4681.  
  4682. 17. Converting DOS Programs/Libraries to DJGPP
  4683. **********************************************
  4684.  
  4685.   If you have a program or a library developed under some other DOS-based
  4686. compiler, which you want to port to DJGPP, read this chapter.
  4687.  
  4688. 17.1 GCC/Gas won't accept valid assembly code ...
  4689. =================================================
  4690.  
  4691. **Q*: I have some code written in assembly which compiles under `MASM' and
  4692. `TASM', but GCC gives me a long list of error messages.*
  4693.  
  4694. *A* :  The GNU Assembler (`as.exe'), or `Gas' called by GCC accepts "AT&T"
  4695. syntax, which is different from "Intel" syntax.  Notable differences between
  4696. the two syntaxes are:
  4697.  
  4698.    * AT&T immediate operands are preceded by `$'; Intel immediate operands
  4699.      are undelimited (Intel `push 4' is AT&T `pushl $4').
  4700.  
  4701.    * AT&T register operands are preceded by `%'; Intel register operands are
  4702.      undelimited.  AT&T absolute (as opposed to PC-relative) `jump'/`call'
  4703.      operands are prefixed by `*'; they are undelimited in Intel syntax.
  4704.  
  4705.    * AT&T and Intel syntax use the opposite order for source and destination
  4706.      operands.  Intel `add eax, 4' is `addl $4, %eax' in AT&T syntax.
  4707.  
  4708.      The `source, dest' convention is maintained for compatibility with
  4709.      previous Unix assemblers, so that GCC won't care about the assembler with
  4710.      which it is configured, as some of GCC installations (on systems other
  4711.      than MS-DOS) don't use GNU Binutils.
  4712.  
  4713.    * In AT&T syntax, the size of memory operands is determined from the last
  4714.      character of the opcode name.  Opcode suffixes of `b', `w', and `l'
  4715.      specify byte (8-bit), word (16-bit), and long (32-bit) memory
  4716.      references.  Intel syntax accomplishes this by prefixing memory operands
  4717.      (*not* the opcodes themselves) with ``byte ptr'', ``word ptr'', and
  4718.      ``dword ptr'.'  Thus, Intel `mov al, byte ptr FOO' is `movb FOO, %al' in
  4719.      AT&T syntax.
  4720.  
  4721.    * Immediate form long jumps and calls are `lcall/ljmp $SECTION, $OFFSET'
  4722.      in AT&T syntax; the Intel syntax is `call/jmp far SECTION:OFFSET.'
  4723.      Also, the far return instruction is `lret $STACK-ADJUST' in AT&T syntax;
  4724.      Intel syntax is `ret far STACK-ADJUST.'
  4725.  
  4726.    * The AT&T assembler does not provide support for multiple-section (aka
  4727.      multi-segment) programs.  Unix style systems expect all programs to be
  4728.      single-section.
  4729.  
  4730.    * An Intel syntax indirect memory reference of the form
  4731.  
  4732.            SECTION:[BASE + INDEX*SCALE + DISP]
  4733.  
  4734.      is translated into the AT&T syntax
  4735.  
  4736.            SECTION:DISP(BASE, INDEX, SCALE)
  4737.  
  4738. Examples:
  4739.  
  4740.          *Intel:*  [ebp - 4]         *AT&T:*  -4(%ebp)
  4741.          *Intel:*  [foo + eax*4]     *AT&T:*  foo(,%eax,4)
  4742.          *Intel:*  [foo]             *AT&T:*  foo(,1)
  4743.          *Intel:*  gs:foo            *AT&T:*  %gs:foo
  4744.  
  4745. For a complete description of the differences, get and unzip the files named
  4746. `as.iN' (where `N' is a digit) from the bnu27b.zip, e.g.
  4747. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bnu27b.zip archive, then
  4748. see See i386-dependent features in "GNU assembler documentation", or point
  4749. your Web browser to http://www.delorie.com/gnu/docs/gas/as_190.html#SEC192.
  4750. If you don't read this FAQ with an Info browser, type at the DOS prompt:
  4751.  
  4752.       info as machine i386
  4753.  
  4754. You will see a menu of `Gas' features specific to x86 architecture.
  4755.  
  4756. A guide is available which was written by Brennan Mr. Wacko Underwood
  4757. <brennan@mack.rt66.com>; it describes how to use inline assembly programming
  4758. with DJGPP and includes a tutorial on the AT&T assembly syntax.  Check out
  4759. the DJGPP inline assembly tutorial, at this URL:
  4760.  
  4761.      http://www.rt66.com/~brennan/djgpp/djgpp_asm.html
  4762.  
  4763. Many people who used Intel syntax and then converted to the AT&T style say
  4764. that they like the AT&T variant more.  However, if you prefer to stick with
  4765. the Intel syntax, download and install NASM, e.g.
  4766. ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/nasm091.zip, which is a free
  4767. portable assembler.  It is compatible with DJGPP and accepts a syntax which
  4768. is almost 100% compatible with the Intel style.
  4769.  
  4770. 17.2 Double-check code produced by Gas
  4771. ======================================
  4772.  
  4773. **Q*: My assembly code gets corrupted by `Gas'!*
  4774.  
  4775. *A* :  When writing assembly code, you should remember *to not trust Gas!*
  4776. You should always check that it does what you expect it to do.  GNU Assembler
  4777. can currently be trusted only when it assembles code produced by GCC.  All
  4778. other code--yours--is subject to the introduction of subtle errors.  To be
  4779. sure, use a debugger to check the code (even `objdump' from GNU Binutils
  4780. doesn't always treat segment overrides correctly).  The following lists some
  4781. guidelines for safer machine-language programming with `Gas':
  4782.  
  4783.   a. Use explicit sizing.  E.g., use `movl' instead of `mov', even if you're
  4784.      sure the arguments are 32-bit wide.  The fact that you use byte
  4785.      registers doesn't seem to matter with `Gas.'
  4786.  
  4787.   b. Write code segment overrides as `.byte' constants, not as e.g.  `%cs:.'
  4788.      According to Charles Sandmann <sandmann@clio.rice.edu>, `Gas' uses the
  4789.      current phase of the moon in deciding whether to ignore your prefixes.
  4790.      So unless you know *exactly* what the phase of the moon is at the moment
  4791.      of assembly, use `.byte' constants.
  4792.  
  4793.   c. Make sure the operands match the instructions.  Don't assume that if they
  4794.      don't, you'll get an error message from the assembler.
  4795.  
  4796. 17.3 Converting Intel ASM syntax to AT&T syntax
  4797. ===============================================
  4798.  
  4799. **Q*: Where can I find an automated conversion tool to convert my
  4800. `Intel'-style assembly code into a code acceptable by `Gas'?*
  4801.  
  4802. *A* :  A `Sed' script which should do most of the conversion was posted to
  4803. the DJGPP news group in the past.  You can find it in the DJGPP archives, at
  4804. this URL:
  4805.  
  4806.      http://www.delorie.com/djgpp/mail-archives/djgpp/1995/06/06/05:48:34
  4807.  
  4808. A conversion program called `TA2AS' which can convert TASM assembly source to
  4809. the AT&T format, can be found on the DJGPP server, e.g.
  4810. ftp://ftp.delorie.com/pub/djgpp/contrib/ta2asv08.zip and on the Oulu
  4811. repository, e.g. ftp://x2ftp.oulu.fi/pub/msdos/programming/convert/ta2as.zip.
  4812. `TA2AS' was written by Jan Oonk <jan@stack.urc.tue.nl>.
  4813.  
  4814. Alternatively, here is what you can do to make your code linkable with DJGPP
  4815. programs:
  4816.  
  4817.    * Get and install NASM, a portable x86 assembler which supports most of
  4818.      the Intel syntax and can generate DJGPP-compatible COFF object files (as
  4819.      well as lots of other formats, such as Microsoft 16-bit OBJ and Win32,
  4820.      a.out, and ELF).  It also supports Pentium and Pentium Pro opcodes.
  4821.      NASM is free for non-commercial use (see the docs for commercial use
  4822.      restrictions) and can be compiled with DJGPP.  You can get NASM from
  4823.      sunsite mirrors, e.g.
  4824.      ftp://sunsite.unc.edu/pub/Linux/devel/lang/asm/nasm-0.90.tar.gz.  A
  4825.      pre-compiled MSDOS binary is available from SimTel.NET sites, e.g.
  4826.      ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/nasm091.zip.  The author
  4827.      and maintainer of NASM is Simon Tatham <sgt20@cam.ac.uk>.
  4828.  
  4829.    * For a small number of relatively short files, consider converting them
  4830.      with a smart editor (like Emacs or its work-alikes).
  4831.  
  4832.    * Obtain a copy of Microsoft MASM 6.11. It has a `-coff' option to
  4833.      generate object code in COFF format which can be submitted to GCC, so you
  4834.      can compile your original source.  You can also use the `LIB32'
  4835.      librarian from Microsoft C8 to convert object files to COFF by putting
  4836.      them into a `.lib' library, then extracting them as COFF files.  (If you
  4837.      use MASM or LIB32, please post your experiences to comp.os.msdos.djgpp
  4838.      news group, so that I can make the above instructions less vague.)
  4839.  
  4840.    * Use a disassembler to disassemble the object code, then convert it to
  4841.      the AT&T format either by hand or using `TA2AS'.  One place to look for
  4842.      such a disassembler is on SimTel.NET mirrors, e.g.
  4843.      ftp://ftp.simtel.net/pub/simtelnet/msdos/disasm/.
  4844.  
  4845. Keep in mind that syntax is only one of the aspects of converting code
  4846. written for DOS to DJGPP.  You should also make sure your code doesn't
  4847. violate any of the rules for protected-mode programming (see next question in
  4848. Section 17.4).
  4849.  
  4850. 17.4 Converted code GP Faults!
  4851. ==============================
  4852.  
  4853. **Q*: OK, I've succeeded in converting and compiling my assembly-language
  4854. program, but when I run it, I get "Segmentation Violation" and "General
  4855. Protection Fault".  This program works when compiled with MASM, so how can
  4856. this be?*
  4857.  
  4858. *A* :  In DJGPP, your program runs in *protected mode*.  There are certain
  4859. things you can't do in protected-mode programs (that's why it is called
  4860. protected mode).  This issue is too complex to describe here, so only a few
  4861. of the more important aspects will be briefly mentioned.  If you are serious
  4862. about writing assembly language protected-mode code, or have a large body of
  4863. existing code to convert to protected mode, you should read any of the
  4864. available books about protected-mode programming with 80x86 processors.
  4865.  
  4866. Here is a short list of some of the techniques found in many real-mode
  4867. programs, which will trigger protection violation or erratic behavior in
  4868. protected mode:
  4869.  
  4870.    * Loading arbitrary values into segment registers, then using them to
  4871.      reference code or data.
  4872.  
  4873.    * Referencing code with data segment register, or vice versa.
  4874.  
  4875.    * Assuming certain locations (like BIOS area or video memory) will be found
  4876.      at certain absolute addresses.
  4877.  
  4878.    * Calling DOS or BIOS services with `INT NN' instruction.
  4879.  
  4880. 17.5 I want to use a `.obj' or `.lib' code with DJGPP
  4881. =====================================================
  4882.  
  4883. **Q*: I have a set of useful functions in a `.obj' format, but no source
  4884. code.  Can I use them with my DJGPP program?*
  4885.  
  4886. **Q*: I have this `ACMELUXE.LIB' library of functions which I want to use.
  4887. I've extracted all the `.obj' files, but when I try to link them with my
  4888. program, GCC complains: "File format not recognized".  Can't I use these
  4889. object files?*
  4890.  
  4891. **Q*: I've got a bunch of `.obj' files I want to use.  I've ran AR to make a
  4892. GCC-style `.a' object library, but got an error message from GCC saying
  4893. "couldn't read symbols: No symbols".  How can I link them with my code?*
  4894.  
  4895. *A* : Sorry, you probably can't.  The GNU linker called by GCC doesn't
  4896. understand the format of `.obj' files which other DOS-based
  4897. compilers/assemblers emit.  Unless you can get the source of those functions,
  4898. convert it to protected-mode, flat-address model code and compile them with
  4899. GCC, you most probably won't be able to use them.  (Note that mixing object
  4900. files from different compilers usually won't work either, even if they both
  4901. are in the `.obj' format.)
  4902.  
  4903. Lately, an automated conversion tool called `OBJ2COFF' was written by the
  4904. SPiRiT team, which can be used to convert `.obj' object files and `.lib'
  4905. libraries to `COFF' format, provided that the original `.obj' files have been
  4906. written for flat-address memory model.  (You can also try using LIB32
  4907. librarian from Microsoft C8 to convert object files to COFF.)  The main
  4908. problem, of course, is that most such object files were written for real-mode
  4909. programs in memory models other than flat, and without extensive
  4910. modifications would crash your program anyway... (See previous question in
  4911. Section 17.4.)
  4912.  
  4913. `OBJ2COFF' is available from the Oulu repository, e.g.
  4914. ftp://x2ftp.oulu.fi/pub/msdos/programming/convert/o2cv10.arj and from DJ
  4915. Delorie's ftp server, e.g. ftp://ftp.delorie.com/pub/djgpp/contrib/o2cv06.arj.
  4916. If you have any problems with it or questions about it, send them to its
  4917. author, Rico <mb002@hi.ft.hse.nl> or to George van Venrooij
  4918. <george@il.ft.hse.nl>.  Note that the authors of `OBJ2COFF' have explicitly
  4919. prohibited commercial use, so you shouldn't use `OBJ2COFF' for converting
  4920. commercial object files.
  4921.  
  4922. Another conversion tool you might try is `EMXAOUT' from the `emx/gcc'
  4923. package.  It also requires the code to be written for the flat-address memory
  4924. model and will reportedly complain if you feed it with code written for
  4925. segmented memory models.  `EMXAOUT' is available from the SciTech Software
  4926. FTP site, e.g. ftp://ftp.scitechsoft.com/devel/emxaout1.zip.  If you need,
  4927. you should be able to compile it with DJGPP; however, a precompiled binary is
  4928. available in the above archive.  Or you can get `EMXAOUT' from the EMX
  4929. archives, e.g. ftp://ftp-os2.nmsu.edu/os2/unix/emx09b/emxrt.zip and the RSX
  4930. extender (for running `EMXAOUT' under DPMI) from the RSX archives, e.g.
  4931. ftp://ftp.uni-bielefeld.de/pub/systems/msdos/misc/rsx503rt.zip.
  4932.  
  4933. Note that EMXAOUT produces object files in *a.out* format, whose support in
  4934. DJGPP is not as full as that of *COFF*.  For example, `ld.exe' (as of
  4935. Binutils 2.7) doesn't support a.out object files inside `.a' libraries, so
  4936. you will have to link them as `.o' files.
  4937.  
  4938. 17.6 I *must* use my 16-bit code with DJGPP!!
  4939. =============================================
  4940.  
  4941. **Q*: If that's how it is, then I would have to give up using DJGPP.  I
  4942. simply cannot live without these `.obj' files.  Are you *really* sure there
  4943. is nothing I can do??*
  4944.  
  4945. *A* :  If you need your old code *that* badly, then there might be a way,
  4946. albeit a cumbersome one.  You can write a 16-bit, real-mode program and link
  4947. it with your precious functions you can't live without.  Have this program
  4948. spawn a DJGPP-compiled program and make the two communicate with each other
  4949. via a buffer allocated in low memory, or via command-line parameters passed
  4950. to the 32-bit program by the `spawnXX' function call.  You can also call
  4951. 16-bit functions directly with the library function called
  4952. `__dpmi_simulate_real_mode_procedure_retf', provided the 16-bit program
  4953. passes the CS:IP values of these functions to the 32-bit program.  You can
  4954. even put your 16-bit code as binary instructions into a buffer allocated in
  4955. low memory and call it with `__dpmi_simulate_real_mode_procedure_retf' (but
  4956. if you can do that, you can probably also disassemble the code into a source
  4957. form and submit it to `Gas').
  4958.  
  4959. *Now* will you consider sticking with DJGPP?  *Please??...*
  4960.  
  4961. 17.7 What should I do with those "near" and "far" declarations?
  4962. ===============================================================
  4963.  
  4964. **Q*: I have this program that I need to port to DJGPP, but it is full of
  4965. pointers and functions declared with the "near" and "far" keywords which GCC
  4966. doesn't grok.  What shall I do?*
  4967.  
  4968. **Q*: A program written for a 16-bit compiler uses the MK_FP or _MK_FP macro,
  4969. but DJGPP doesn't seem to have it.  How should I port it?*
  4970.  
  4971. *A* :  In DJGPP you use a flat address space with no segmentation, so you
  4972. don't need far pointers in the sense they are used in 16-bit code.  Just
  4973. define away those keywords and you will be fine:
  4974.  
  4975.        #define far
  4976.        #define near
  4977.        #define huge
  4978.        #define _far
  4979.        #define _near
  4980.        #define _huge
  4981.  
  4982. Alternatively, you could add suitable `-D' switches to the GCC command line,
  4983. like this:
  4984.  
  4985.        gcc -Dfar -Dnear -Dhuge -c myprog.c
  4986.  
  4987. Macros that create far pointers from the segment and offset (usually called
  4988. `MK_FP' or `_MK_FP') are mostly used in 16-bit code to access certain
  4989. absolute addresses on memory-mapped peripheral devices, like the video RAM.
  4990. These chores are done differently in DJGPP.  Here's one possible way to
  4991. express `MK_FP' in DJGPP (courtesy of Charles Sandmann
  4992. <sandmann@clio.rice.edu>):
  4993.  
  4994.        #include <sys/nearptr.h>
  4995.        #include <crt0.h>
  4996.      
  4997.        void * MK_FP (unsigned short seg, unsigned short ofs)
  4998.        {
  4999.          if ( !(_crt0_startup_flags & _CRT0_FLAG_NEARPTR) )
  5000.            if (!__djgpp_nearptr_enable ())
  5001.              return (void *)0;
  5002.          return (void *) (seg*16 + ofs + __djgpp_conventional_base);
  5003.        }
  5004.  
  5005. The above uses the DJGPP nearptr facility; if you prefer to use farptr
  5006. functions (which are safer and work with all known DPMI hosts), you will need
  5007. to rewrite the code that uses these macros, so don't bother writing a
  5008. replacement for the macro itself.  The details are described in Accessing
  5009. absolute addresses in Section 18.4, below.
  5010.  
  5011. Macros that extract the segment and the offset from a far pointer (called
  5012. `FP_SEG' and `FP_OFF') are required in 16-bit code to pass addresses in
  5013. registers when calling real-mode DOS or BIOS services, like functions of
  5014. interrupt 21h.  See How to call real-mode interrupt functions in Section
  5015. 18.2, which describes how that should be done in DJGPP; here, too, you won't
  5016. need to port the macros but instead rewrite the code that calls the DOS or
  5017. BIOS service.
  5018.  
  5019. 17.8 How to convert _AX pseudo-registers?
  5020. =========================================
  5021.  
  5022. **Q*: Since DJGPP doesn't recognize Borland-style pseudo-register variables
  5023. like _AX, how should I port code which uses them to DJGPP?*
  5024.  
  5025. *A* :  These pseudo-variables are typically used in two different contexts:
  5026.  
  5027.    * When calling real-mode interrupt services.
  5028.  
  5029.      To port such code to DJGPP, use the fields of the `__dpmi_regs'
  5030.      structure (declared on the `dpmi.h' header file) to set the register
  5031.      values, and library function `__dpmi_int' to invoke the interrupt
  5032.      service.  For example, consider the following code snippet:
  5033.  
  5034.             #include <dos.h>
  5035.             void _highcolor (void)
  5036.             {
  5037.               _AH = 0x10;
  5038.               _AL = 0x03;
  5039.               _BL = 0;
  5040.               geninterrupt (0x10);
  5041.             }
  5042.  
  5043.      (This calls the video BIOS interrupt 10h to allow bright background
  5044.      colors to be used instead of blinking characters.  DJGPP has a library
  5045.      function, called `intensevideo', to do that, but let's assume we have
  5046.      reasons not to use it.)
  5047.  
  5048.      Here's one way to express this in DJGPP:
  5049.  
  5050.             #include <dpmi.h>
  5051.             void _highcolor (void)
  5052.             {
  5053.               __dpmi_regs r;
  5054.           
  5055.               r.h.ah = 0x10;
  5056.               r.h.al = 0x03;
  5057.               r.h.bl = 0;
  5058.               __dpmi_int (0x10, &r);
  5059.             }
  5060.  
  5061.      Please read How to call real-mode interrupt functions in Section 18.1,
  5062.      elsewhere in this document, for further details on how call real-mode
  5063.      services from DJGPP programs.
  5064.  
  5065.    * Immediately before or after an inline assembly code.
  5066.  
  5067.      GCC features extensive inline assembly facilities which allow you to
  5068.      assign values to, or read values from registers from the inline assembly
  5069.      code.  See Inline Assembly code with GCC in Section 18.13, for further
  5070.      info.
  5071.  
  5072. 18. Low-level DOS/BIOS and Hardware-oriented Programming
  5073. ********************************************************
  5074.  
  5075.   This chapter sheds some light on a few aspects of writing DJGPP programs
  5076. which interact with hardware or use interrupts.
  5077.  
  5078. 18.1 Got "Unsupported INT 0xNN" calling `int86'
  5079. ===============================================
  5080.  
  5081. **Q*: Why does my program crash with "Unsupported DOS request 0xNN" or
  5082. "Unsupported INT 0xNN" when I call `int86' or `intdos' functions to invoke a
  5083. software interrupt?*
  5084.  
  5085. *A* :  Calling real-mode DOS or BIOS services from protected-mode programs
  5086. requires a switch to real mode, so the `int86' family of functions in the
  5087. DJGPP library should reissue the INT instruction after the mode switch.
  5088. However, some services require pointers to memory buffers.  Real-mode
  5089. DOS/BIOS functions can only access buffers in conventional memory, so `int86'
  5090. has to move data between your program and low memory to transparently support
  5091. these services.  But this means it should know about all these services to
  5092. perform these chores correctly, because each service has its own layout and
  5093. size of the buffer(s).  While `int86' supports many of these services, it
  5094. doesn't support all of them.  The supported functions are listed in the
  5095. library reference.  See int86 library reference in "libc.a reference", or
  5096. point your Web browser to
  5097. http://www.delorie.com/djgpp/doc/libc-2.01/libc_411.html#SEC411.  For those it
  5098. doesn't support, you will have to call the `__dpmi_int' library function
  5099. instead.  It is also documented in the library reference, See __dpmi_int in
  5100. "libc.a reference", or point your Web browser to
  5101. http://www.delorie.com/djgpp/doc/libc-2.01/libc_208.html#SEC208.
  5102. `__dpmi_int' requires that you set up all the data as required by the service
  5103. you are calling, including moving the data to and from low memory (See how to
  5104. use buffers with DOS/BIOS services in Section 18.2, below).
  5105.  
  5106. 18.2 How to use buffers with DOS/BIOS services
  5107. ==============================================
  5108.  
  5109. **Q*: I want to call a DOS/BIOS function which requires a pointer to a buffer
  5110. in, e.g. `ES:DI' (or any other) register pair.  How do I get the segment to
  5111. put into the `ES' register?*
  5112.  
  5113. *A* :  If you use `int86x' or `intdosx' for a DOS or BIOS function supported
  5114. by them, then just put the address of your buffer into the register which
  5115. expects the offset (`regs.x.di') and forget about the segment.  These
  5116. functions are processed specially by the library, which will take care of the
  5117. rest.
  5118.  
  5119. If you call `__dpmi_int', then you must put into that register pair an
  5120. address of some buffer in *conventional* memory (in the first 1 MByte).  If
  5121. the size of that buffer doesn't have to be larger than the size of transfer
  5122. buffer used by DJGPP (at least 2KB, 16KB by default), then the easiest way is
  5123. to use the transfer buffer.  (Library functions don't assume its contents to
  5124. be preserved across function calls, so you can use it freely.)  That buffer
  5125. is used for all DOS/BIOS services supported by DJGPP, and it resides in
  5126. conventional memory.  DJGPP makes the address and the size of the transfer
  5127. buffer available for you in the `_go32_info_block' external variable, which
  5128. is documented the library reference.  Check the size of the buffer (usually,
  5129. 16K bytes, but it can be made as small as 2KB), and if it suits you, use its
  5130. linear address this way:
  5131.  
  5132.      dpmi_regs.x.di =
  5133.       _go32_info_block.linear_address_of_transfer_buffer & 0x0f;
  5134.      dpmi_regs.x.es =
  5135.       (_go32_info_block.linear_address_of_transfer_buffer >> 4) & 0xffff;
  5136.  
  5137. For your convenience, the header file `<go32.h>' defines a macro `__tb' which
  5138. is an alias for `_go32_info_block.linear_address_of_transfer_buffer.'
  5139.  
  5140. If the size of the transfer buffer isn't enough, you will have to allocate
  5141. your own buffer in conventional memory with a call to the
  5142. `__dpmi_allocate_dos_memory' library function.  It returns to you the segment
  5143. of the allocated block (the offset is zero).  If you only need a small number
  5144. of such buffers which can be allocated once, then you don't have to worry
  5145. about freeing them: they will be freed by DOS when your program calls `exit.'
  5146.  
  5147. For bullet-proof code, you should test the size of the transfer buffer at
  5148. runtime and act accordingly.  This is because its size can be changed by the
  5149. `STUBEDIT' program without your knowledge (however, it can never be less than
  5150. 2KB, the size of the stub, because memory used by the stub is reused for the
  5151. transfer buffer).
  5152.  
  5153. 18.3 How to call software interrupt functions
  5154. =============================================
  5155.  
  5156. **Q*: My program crashes/doesn't do what it should when I call
  5157. `__dpmi_simulate_real_mode_interrupt.'*
  5158.  
  5159. *A* :  You should zero out some of the fields of the `__dpmi_regs' structure
  5160. before you call that function.  Random values in these fields can cause your
  5161. program to behave erratically.  The fields in point are `SS', `SP' and
  5162. `FLAGS.'  When `SS' and `SP' are zeroed, the DPMI host will provide a stack
  5163. for the interrupt handler.  This stack is locked and is 4KB-long for any
  5164. handling done in protected mode (such as real-mode callbacks), and at least
  5165. 512 bytes in size for interrupts reflected into real mode.  This is usually
  5166. enough, but sometimes you'll need to use your own, larger stack, e.g., if you
  5167. expect interrupts to nest, or if your handler needs a lot of stack space.
  5168. (The DPMI spec indicates that you should *not* use the default stack if your
  5169. procedure/interrupt handler uses more that 60 bytes, or 1/8 of the total
  5170. stack space available by default.)  In these cases you should point `SS' and
  5171. `SP' to a larger buffer which is in conventional memory (possibly part of the
  5172. transfer buffer).
  5173.  
  5174. If `SS:SP' isn't zero, it will be used as the address of the stack for the
  5175. interrupt handler, so if it points to a random location, your program will
  5176. most certainly crash.  A non-zero `FLAGS' field can also make the processor
  5177. do all kinds of weird things (e.g., imagine that the single-step or the debug
  5178. bit is set!).
  5179.  
  5180. If you don't have any reason to set `SS:SP' to a user-defined stack, it's
  5181. easier to call the `__dpmi_int' library function, which zeroes out the stack
  5182. pointer and the `FLAGS' fields for you (and also doesn't force you to type
  5183. long function names!).
  5184.  
  5185. 18.4 How to move data between your program and conventional memory?
  5186. ===================================================================
  5187.  
  5188. **Q*: How can I move data between my program and the transfer buffer?*
  5189.  
  5190. **Q*: How do I access my peripheral card which is memory-mapped to an address
  5191. between 640K and 1M?*
  5192.  
  5193. **Q*: How can I read or change a value of one of the variables in the BIOS
  5194. data area?*
  5195.  
  5196. **Q*: How can I peek at an address whose far pointer I get from an INT 21h
  5197. call?*
  5198.  
  5199. *A* : Usually, memory-mapped devices or absolute addresses below 1MB mark are
  5200. outside your program's address space, so you cannot access them directly.
  5201. "Direct access", when you just dereference a pointer, means in DJGPP that you
  5202. use your program's `DS' selector, and all the addresses are offsets relative
  5203. to the base of that selector.  So first, you will need a special selector
  5204. that will allow you to access your device or absolute address.  There are
  5205. several methods you can get such a selector:
  5206.  
  5207.    * Use the selector that DJGPP creates for itself to access conventional
  5208.      memory.  DJGPP makes this selector available to you via the `_dos_ds'
  5209.      macro (defined on `<go32.h>' header file).  This selector has base
  5210.      address of 0 and a limit of 1MB, so you can use it to access any address
  5211.      in the conventional memory, but the relatively large limit allows a
  5212.      buggy program to overwrite portions of DOS memory.  (Original release of
  5213.      DJGPP v2.01 makes the limit of `_dos_ds' be 4GB, which effectively
  5214.      disables memory protection when you use that selector.  However, since
  5215.      no memory outside the first 1MB is properly mapped into your program's
  5216.      address space without additional DPMI calls, and the DPMI host is then
  5217.      free to put memory-mapped devices, such as Weitek I/O space or the
  5218.      linear frame buffer of an SVGA, on any address it sees fit, that huge
  5219.      limit is an unjustified security hole.) The advantage of `_dos_ds' is
  5220.      obviously that you don't have to create it, and that it is good for
  5221.      accessing every region in the first MByte range.
  5222.  
  5223.    * Create your own selector that spans only the region of memory that you
  5224.      want to access, and use that selector instead of `_dos_ds'.  For
  5225.      example, here's a code snippet to set up a selector which provides
  5226.      access to 64KB of text-mode video memory at `0xB800:0000', courtesy of
  5227.      Bill Currie <bill_currie@blackmagic.tait.co.nz>:
  5228.  
  5229.             int TxtVRAMSetupSelector (void)
  5230.             {
  5231.                static char selectorData[8] = {
  5232.                  0xff, 0xff, 0x00, 0x80,
  5233.                  0x0b, 0xf3, 0x40, 0x00
  5234.                };
  5235.                int screenSelector = __dpmi_allocate_ldt_descriptors (1);
  5236.                if (__dpmi_set_descriptor (screenSelector, selectorData) < 0)
  5237.                  abort ();
  5238.                return screenSelector;
  5239.             }
  5240.  
  5241.      The advantages of this method are that (1) you can set up the selector
  5242.      limit such that it only covers the memory region that you need, thus
  5243.      protection of the rest of memory is retained; and (2) you may set the
  5244.      base address to point to the beginning of the specific memory region you
  5245.      need to access, so that you don't have to add the base address for every
  5246.      access, making the access faster.  For details about the contents of the
  5247.      8-byte selector descriptor, see the documentation of the
  5248.      `__dpmi_get_descriptor' function in the library reference Info file.
  5249.  
  5250.    * Use the DPMI service which creates a selector to access a specific
  5251.      real-mode segment address.  The DJGPP library has a function
  5252.      `__dpmi_segment_to_descriptor' which is a wrapper around that DPMI
  5253.      service.  It is easier to use than the `__dpmi_set_descriptor' function
  5254.      above, since you don't have to mess with the 8-byte descriptor buffer,
  5255.      but it always defines a 64KB limit by default.  Here is an example of
  5256.      code which gets a selector to access 64KB of video RAM beginning at
  5257.      `0xA000:0000':
  5258.  
  5259.             short video = __dpmi_segment_to_descriptor(0xa000);
  5260.  
  5261.      Note that descriptors created by this function should never be modified
  5262.      or freed.  For this reason, you should use this function sparingly.  For
  5263.      instance, if your program needs to examine various real mode addresses
  5264.      using the same selector, you should allocate a descriptor and change the
  5265.      base using the `__dpmi_set_segment_base_address' library function
  5266.      instead of using `__dpmi_segment_to_descriptor' to allocate separate
  5267.      descriptor for each address.
  5268.  
  5269. Once you have a selector, you can use one of three methods to access your
  5270. absolute addresses using that selector:
  5271.  
  5272.    * If you want to access a byte, a 16-bit word, or a 32-bit double word,
  5273.      use the "far pointer" functions declared on the `<sys/farptr.h>' header
  5274.      file.  You should convert any real-mode far pointer segment:offset pair
  5275.      into a "linear address" (i.e., segment*16 + offset), and use `_dos_ds'
  5276.      or any other selector which allows access to conventional memory, like
  5277.      this:
  5278.  
  5279.            unsigned char value = _farpeekb(_dos_ds, segment*16 + offset);
  5280.  
  5281.      Use `_farpeekw' to peek at 16-bit shorts and `_farpeekl' to peek at
  5282.      32-bit longs.  If you need to access several (non-contiguous) values in
  5283.      a loop, use the corresponding `_farnspeekX' functions which allow you to
  5284.      set the selector only once, as opposed to passing it with every call
  5285.      (but be sure the loop doesn't call any function that itself sets the
  5286.      selector; see the library reference for more details).
  5287.  
  5288.      There is a corresponding set of `_farpokeX' and `_farnspokeX' functions
  5289.      to poke (change the values of) such memory locations.
  5290.  
  5291.      These functions have an advantage of emitting inline assembly code when
  5292.      you compile with optimizations, so they are very fast.  See the library
  5293.      reference Info file for further details about these functions.
  5294.  
  5295.    * If you need to access more than 4 contiguous bytes, use `dosmemget' and
  5296.      `dosmemput' library functions.  They also require you to convert the
  5297.      segment:offset pair into a linear address, but they don't need the
  5298.      conventional memory selector, as they can only be used to access the
  5299.      conventional memory (they use `_dos_ds' internally).
  5300.  
  5301.      Note that some memory-mapped peripheral devices might require 16-bit word
  5302.      accesses to work properly, so if `dosmemXXX' yields garbled results, try
  5303.      `dosmemXXXw' or "farptr" functions.
  5304.  
  5305.    * For moving buffers to selectors other than `_dos_ds' (e.g., created by
  5306.      one of the methods explained above), use the `movedata' library
  5307.      function.  It requires that you pass a selector and an offset for both
  5308.      the conventional memory address and for the buffer in your program's
  5309.      address space.  Use the `_my_ds' function (note that it's a *function*,
  5310.      not a variable!) to get the selector of any variable in your program,
  5311.      and use the address of the variable (cast to an `int') as its "offset"
  5312.      or linear address.  `movedata' is fast because it moves by 32-bit longs,
  5313.      but be careful with its use when moving data to and from peripheral
  5314.      cards: some of them only support 8- or 16-bit wide data path, so moving
  5315.      data 4 bytes at a time won't gain you much, and might even get you in
  5316.      trouble with some buggy BIOSes.  The functions `movedatab' and
  5317.      `movedataw' are provided for moving by bytes and by 16-bit words,
  5318.      respectively.
  5319.  
  5320.      For example, here is a code snippet that combines one of the methods for
  5321.      allocating a descriptor for video RAM access with a call to `movedata'
  5322.      to move a buffer to the graphics screen:
  5323.  
  5324.             short video = __dpmi_segment_to_descriptor(0xa000);
  5325.             movedata(_my_ds(), buffer, video, 0, 320*200);
  5326.  
  5327.    * For the fastest access to memory outside your usual address space, you
  5328.      might consider using the "nearptr" functions declared on the
  5329.      `<sys/nearptr.h>' header; see the library reference for more details.
  5330.      Also see the description of how to get the fastest direct access to
  5331.      peripheral devices in Section 18.6, below.
  5332.  
  5333. 18.5 Conventional-memory addresses use only 20 bits
  5334. ===================================================
  5335.  
  5336. **Q*: I call `movedata' to pass data between my program and the transfer
  5337. buffer, but get bogus values or General Protection Fault.*
  5338.  
  5339. *A* :  Valid conventional-memory addresses are only 20 bit-wide.  However,
  5340. the value stored in the variable
  5341. `_go32_info_block.linear_address_of_transfer_buffer' (or its alias, `__tb')
  5342. is not guaranteed to have the higher 12 bits zeroed, and `movedata' doesn't
  5343. mask those high bits, because it can also be used to move data between 2
  5344. protected-memory locations.  Be sure to mask off the high 12 bits of the
  5345. value returned by various `..._linear_address_...' fields in DJGPP
  5346. structures, whenever that address references a conventional memory location,
  5347. before you call *any* of the functions from the `movedataX' family, the
  5348. "farptr" or the "nearptr" functions.
  5349.  
  5350. 18.6 Fast access to memory-mapped devices or absolute addresses
  5351. ===============================================================
  5352.  
  5353. **Q*: The "farptr" functions are too slow for my application which *MUST*
  5354. have direct access to a memory-mapped device under DPMI.  How can I have this
  5355. in DJGPP?  My entire optimized graphics library is at stake if I can't! :(*
  5356.  
  5357. *A* :  The following so-called Fat DS method was suggested by Junaid A.
  5358. Walker <junaid@barney.eng.monash.edu.au> (he also posted a program which uses
  5359. this technique to access the video RAM; you can look it up by searching the
  5360. mailing list archives).  But first, a word of warning: the method I'm about
  5361. to describe effectively disables memory protection, and so might do all kinds
  5362. of damage if used by a program with a wild pointer.  Or, as Stephen Turnbull
  5363. <turnbull@shako.sk.tsukuba.ac.jp> has put it:
  5364.  
  5365.      *Surgeon General's WARNING*:  The description below uses the "Fat DS
  5366.      hack", a steroid derivative which gives your program great strength, a
  5367.      thick neck, baldness, and is known to be closely linked with the
  5368.      Alzheimer's disease.
  5369.  
  5370. Having said that, here is the trick: you change the limit of the segment
  5371. descriptor stored in `DS' to `0xffffffff' (i.e., -1), using function 8 of the
  5372. DPMI interrupt 31h.  After that, you have access to all the memory which is
  5373. currently mapped in.  You then use the 32-bit wrap-around in the linear
  5374. address space to access memory at, say, linear address 0xa0000 (which belongs
  5375. to the VGA), or any other address on your memory-mapped device.
  5376.  
  5377. You should know up front that this trick won't work with every DPMI host.
  5378. Linux's DOSEmu and Win/NT won't allow you to set such a huge limit on the
  5379. memory segment, because these operating systems take memory protection
  5380. seriously; in these cases `__djgpp_nearptr_enable' will return zero--a sign
  5381. of a failure.  CWSDPMI, QDPMI, Win 3.x and Win 9x all allow this technique
  5382. (OS/2 Warp seems to allow it too, at least as of version 8.200), but some
  5383. events break this scheme even for those DPMI hosts which will allow it.  A
  5384. call to `malloc' or any other library function which calls `sbrk' might
  5385. sometimes change the base address of the `DS' selector and break this method
  5386. unless the base address is recomputed after `sbrk' call.  (The "nearptr"
  5387. functions support this recomputation by providing you with the
  5388. `__djgpp_conventional_base' variable, but it is your responsibility to use
  5389. it.)  The same change happens when you call `system', and as a result of some
  5390. other events external to the executing code thread, like multitasking or
  5391. debugger execution.
  5392.  
  5393. You should also know that the `__djgpp_nearptr_enable' function in DJGPP v2.0
  5394. didn't verify that the limit was properly set.  So if the DPMI server would
  5395. fail the call *silently*, the function won't detect it and will not return a
  5396. failure indication.  DJGPP v2.01 corrects this omission by always verifying
  5397. that the DPMI host has honored the request, and returns a failure indication
  5398. if it hasn't.
  5399.  
  5400. If you are aware of these limitations, and don't need your code to run under
  5401. all DPMI hosts, it might be the fix to your problems.
  5402.  
  5403. Confused about how exactly should you go about using this technique in your
  5404. program?  Look at the docs of the "nearptr" functions, See
  5405. __djgpp_nearptr_enable in "libc.a reference", or point your Web browser to
  5406. http://www.delorie.com/djgpp/doc/libc-2.01/libc_122.html#SEC122.
  5407.  
  5408. Another possibility is to use the DPMI function `0x508' that can map any
  5409. range of physical memory addresses into a block that you allocate.  Note that
  5410. this is a DPMI 1.0 functionality which is *not* supported by most DPMI 0.9
  5411. hosts (`CWSDPMI' does support it).  There is a helper function
  5412. `__djgpp_map_physical_memory' in the DJGPP C library that you can use to call
  5413. these services.
  5414.  
  5415. 18.7 Accessing absolute address above 1MB
  5416. =========================================
  5417.  
  5418. **Q*: How can I access memory-mapped peripheral devices (or any other
  5419. absolute address) above 1 MByte mark?*
  5420.  
  5421. *A* :  You should use DPMI functions to allocate an LDT descriptor, and map
  5422. it to an absolute physical address.  You can then use the functions from
  5423. <sys/farptr.h> to access that linear address.  These are the DPMI calls that
  5424. you will have to use:
  5425.  
  5426.    - allocate an LDT descriptor (Int 31h/AX=0);
  5427.  
  5428.    - map selector to physical address (Int 31h/AX=0800h);
  5429.  
  5430.    - lock linear address (Int 31h/AX=0600h);
  5431.  
  5432.    - set segment base address (Int 31h/AX=7);
  5433.  
  5434.    - set segment limit (Int 31h/AX=8).
  5435.  
  5436. All of these DPMI calls have `__dpmi__XXX' wrappers in the DJGPP library.
  5437.  
  5438. 18.8 How to make DOS/BIOS call your function
  5439. ============================================
  5440.  
  5441. **Q*: How can I make any real-mode service call my function?  E.g., the mouse
  5442. driver has a provision (function 0Ch) to call a user-defined handler when
  5443. certain events occur, which expects a far pointer to my function in the
  5444. `ES:DX' register pair.*
  5445.  
  5446. *A* :  Those services expect a real-mode function, so you should wrap your
  5447. protected-mode function with a real-mode stub.  To this end, call either the
  5448. `_go32_dpmi_allocate_real_mode_callback_retf' or the
  5449. `_go32_dpmi_allocate_real_mode_callback_iret' library function, as required
  5450. by the real-mode service you want to hook, and pass the `segment' and
  5451. `offset' fields it returns to the service you want (in the above example, Int
  5452. 33h function 0Ch) by calling `__dpmi_int.' Here's a code fragment that shows
  5453. how to do this:
  5454.  
  5455.  
  5456.        #include <dpmi.h>
  5457.        #include <go32.h>
  5458.      
  5459.        static __dpmi_regs        callback_regs;
  5460.        static _go32_dpmi_seginfo callback_info;
  5461.      
  5462.        int install_mouse_handler (unsigned mask,
  5463.                                   void (*func)(__dpmi_regs *))
  5464.        {
  5465.          __dpmi_regs r;
  5466.      
  5467.          callback_info.pm_offset = (long)func;
  5468.          if (_go32_dpmi_allocate_real_mode_callback_retf(&callback_info,
  5469.                                                          &callback_regs))
  5470.            return -1;  /* failure */
  5471.      
  5472.          r.x.ax = 0xc;
  5473.          r.x.cx = mask;
  5474.          __dpmi_int (0x33, &r);
  5475.          return (r.x.flags & 1) ? -1 : 0;
  5476.        }
  5477.  
  5478. The handler (`func' in the above example) will be called with a pointer to a
  5479. `__dpmi_regs' structure which is filled by values found in the CPU registers
  5480. when the mouse driver calls the handler.  See the docs in the library
  5481. reference Info file for further details about allocating wrapper functions.
  5482.  
  5483. 18.9 How to hook hardware interrupts
  5484. ====================================
  5485.  
  5486. **Q*: How do I register my DJGPP function as a hardware interrupt handler?*
  5487.  
  5488. *A* :  The optimal setup depends on the interrupt frequency and on the amount
  5489. of processing it requires.  Therefore, only some basic considerations and
  5490. techniques are listed below.  What combination of these is best for your
  5491. application is up to you to decide.
  5492.  
  5493. First, some background.  Hardware interrupts can occur when the processor is
  5494. either in real mode (like when your program calls some DOS service) or in
  5495. protected mode.  When your program runs under a DPMI host, hardware
  5496. interrupts are caught by the DPMI host and passed to protected mode first;
  5497. only if unhandled, they are then reflected to real mode.  Therefore, in DPMI
  5498. mode you can get away with installing only a protected-mode handler.
  5499. However, if the interrupts happen at a high frequency (say, more than 10
  5500. KHz), then the overhead of the interrupt reflection from real to protected
  5501. mode might be too painful, and you should consider installing a real-mode
  5502. interrupt handler in addition to the protected-mode one.  Such a real-mode
  5503. handler will be called *before* the interrupt gets to the DPMI host, and
  5504. handle the interrupt entirely in real mode, so it must be written in assembly
  5505. and located in conventional memory (below the 1MB mark).  If you need to hook
  5506. an interrupt with both PM and RM handlers, you must hook the PM interrupt
  5507. first, then the RM one (because hooking the PM interrupt modifies the RM
  5508. one).  Also, you should know that some DPMI hosts don't allow you to hook the
  5509. RM interrupt (CWSDPMI does); the only way to be sure is to try.
  5510.  
  5511. To install a protected-mode interrupt handler, you do this:
  5512.  
  5513.    * In general, your handler should be written in assembly to be
  5514.      bullet-proof.  It should lock all the memory (code, data and stack) it
  5515.      touches during interrupt processing (this is virtually impossible in C),
  5516.      explicitly issue the `STI' instruction before `IRET' and perform all the
  5517.      other chores described in the DPMI spec (see DOS Protected Mode Interface
  5518.      Specification in Section 22.4).  To install assembly handler, you should
  5519.      do this:
  5520.  
  5521.         - Call `__dpmi_get_protected_mode_interrupt_vector' and save the
  5522.           structure it returns (to restore the previous handler address
  5523.           before your program exits).
  5524.  
  5525.         - Lock all the memory your handler touches with a series of calls to
  5526.           `__dpmi_lock_linear_region.'
  5527.  
  5528.         - Finally, call `__dpmi_set_protected_mode_interrupt_vector' passing
  5529.           it the pointer to a `__dpmi_paddr' structure filled with `_my_cs'
  5530.           in the `selector' field and the address of your function in the
  5531.           `offset32' field.
  5532.  
  5533.    * If your handler function is written in C, you should generally call the
  5534.      `_go32_dpmi_XXX' functions instead of the bare-bones API wrappers whose
  5535.      names start with `__dpmi_.'  Specifically:
  5536.  
  5537.         - Call `_go32_dpmi_get_protected_mode_interrupt_vector.'  This
  5538.           function puts the selector and offset of the specified interrupt
  5539.           vector into the `pm_selector' and `pm_offset' fields of the
  5540.           structure pointed to by its second argument.  This data should be
  5541.           saved and later passed to
  5542.           `_go32_dpmi_get_protected_mode_interrupt_vector' to restore the
  5543.           vector on exit.
  5544.  
  5545.         - Call `_go32_dpmi_allocate_iret_wrapper,' passing it the address of
  5546.           your functions in the `pm_offset' field and the value of `_my_cs'
  5547.           in the `pm_selector' field.  The `pm_offset' field will get
  5548.           replaced with the address of the wrapper function which is a small
  5549.           assembler function that handles everything an interrupt handler
  5550.           should do on entry and before exit (and what the code GCC generates
  5551.           for an ordinary C function doesn't include); the effect is similar
  5552.           to using interrupt or `_interrupt' keyword in some DOS-based
  5553.           compilers.
  5554.  
  5555.         - If you want your handler to chain to the previous handler, call
  5556.           `_go32_dpmi_chain_protected_mode_interrupt_vector.'  This will set
  5557.           up a wrapper function which, when called, will call your handler,
  5558.           then jump to the previous handler after your handler returns.  Put
  5559.           the address of your handler into the `pm_offset' field and the
  5560.           value of `_my_cs' into the `pm_selector' field of the
  5561.           `_go32_dpmi_seginfo' structure and pass a pointer to it to this
  5562.           function.
  5563.  
  5564.         - You then call `_go32_dpmi_set_protected_mode_interrupt_vector' with
  5565.           the address of the `_go32_dpmi_seginfo' structure you got either
  5566.           from `_go32_dpmi_allocate_iret_wrapper' or from
  5567.           `_go32_dpmi_chain_protected_mode_interrupt_vector.'
  5568.  
  5569.      The problem with writing handlers in C as above is that the wrappers'
  5570.      code and data aren't locked, and in practice you can't lock all of
  5571.      memory the handler itself uses, either.  Thus, this approach is
  5572.      generally unsuitable for production-quality software and should be used
  5573.      only when the program is known not to page (i.e., only the physical
  5574.      memory is used).  You might consider disabling virtual memory to make
  5575.      sure your program doesn't page.  To accomplish this, either set the
  5576.      `_CRT0_FLAG_LOCK_MEMORY' bit in the `_crt0_startup_flags' variable, or
  5577.      use `CWSDPR0' or `PMODE/DJ' as your DPMI host.  In fact, using one of
  5578.      these methods is the recommended way of debugging the first versions of
  5579.      a program that hooks hardware interrupts; only after you are sure that
  5580.      your basic machinery works should you move to testing it in a setup when
  5581.      paging might happen.
  5582.  
  5583.      Note that `_CRT0_FLAG_LOCK_MEMORY' is only recommended for small
  5584.      programs that run on a machine where enough physical memory is always
  5585.      available, because the startup code currently doesn't test if memory is
  5586.      indeed locked, and you can end up with unlocked, or partially unlocked
  5587.      memory, which will crash your program.
  5588.  
  5589. To install a real-mode interrupt handler, you do this:
  5590.  
  5591.    * Call `__dpmi_get_real_mode_interrupt_vector' and save the structure it
  5592.      returns (to restore the previous handler address before your program
  5593.      exits).
  5594.  
  5595.    * Allocate some conventional memory with `__dpmi_allocate_dos_memory' and
  5596.      put the code of your handler there with the `dosmemput' function.  (You
  5597.      could also call one of the functions which allocate a real-mode
  5598.      call-back, but these will cause a mode switch on every interrupt, which
  5599.      you want to avoid; otherwise there is no point in installing a real-mode
  5600.      handler, right?)
  5601.  
  5602.    * Put the address which `__dpmi_allocate_dos_memory' returned into a
  5603.      `__dpmi_raddr' structure (the lower 4 bits into `offset16' field, the
  5604.      rest into `segment' field), then call
  5605.      `__dpmi_set_real_mode_interrupt_vector.'
  5606.  
  5607. For examples of installing and using hardware interrupt handlers, see the
  5608. sample code written by Bill Currie <bill_currie@MAIL.TAIT.CO.NZ>, the Sound
  5609. Blaster interrupt-driven functions, the `mkkbd' package, and the `libhw'
  5610. library, described under sample DJGPP packages in Section 22.2.  Alaric B.
  5611. Williams <alaric@abwillms.demon.co.uk> has written a tutorial on DJGPP
  5612. interrupt handling, at this URL:
  5613.  
  5614.      http://www.abwillms.demon.co.uk/prog/djints.txt
  5615.  
  5616. 18.10 Should I use _go32_XXX or __dpmi_YYY functions?
  5617. =====================================================
  5618.  
  5619. **Q*: In v1.x I was used to the `_go32_...' functions, but now comes v2 which
  5620. also has `__dpmi_...' functions.  Are there any differences between these two
  5621. varieties?*
  5622.  
  5623. **Q*: Do I need to convert my old v1.x code to use the new `__dpmi_...'
  5624. functions?*
  5625.  
  5626. *A* :  These two groups of functions have different functionality, so don't
  5627. just substitute the new ones for the older ones, because it usually won't
  5628. work!  The new `__dpmi_...' functions are just bare-bones wrappers of the
  5629. DPMI API calls (see DPMI Specification in Section 22.4), generally unsuitable
  5630. for use with handlers written in C, whereas the old `_go32_...' functions are
  5631. intelligent helper functions which only make sense if your interrupt handlers
  5632. are C functions.  The problem with the `_go32_...' functions is that they
  5633. don't lock all the code and data they (and your handlers) use, so they can
  5634. crash on memory-tight machines and thus aren't suitable for
  5635. production-quality code.  But they are certainly useful in the initial stages
  5636. of writing and debugging code that hooks hardware interrupts, and for
  5637. migrating existing v1.x code to v2.  Some of the old names were just
  5638. `#define'd' to the new names where the functionality is identical.
  5639.  
  5640. The bottom line is that it shouldn't be necessary to convert your code for it
  5641. to work at least as well as it did in v1.x; but if you want it to be more
  5642. stable, you should rewrite your handlers in assembly and use the new
  5643. `__dpmi_...' functions (see How to install a hardware interrupt handler in
  5644. Section 18.9).
  5645.  
  5646. 18.11 Hardware interrupt hooking has its subtleties ...
  5647. =======================================================
  5648.  
  5649. **Q*: I did all the above, but my program occasionally still hangs...*
  5650.  
  5651. *A* :  Hooking hardware interrupts in DJGPP (and in protected mode in
  5652. general) has a few subtle aspects.  In general, hardware interrupt handling
  5653. in DJGPP v2.x is rock solid *if you play by the rules*.  Unfortunately, the
  5654. rules are a bit tricky.
  5655.  
  5656. One cause of your problems might be that your interrupt handler or some
  5657. memory location it uses get paged out because of the virtual memory
  5658. mechanism, or because your program spawned a child program.  In that case,
  5659. the interrupt might cause a call to a non-existent service routine, with the
  5660. obvious results.  You should lock all the memory pages that your handler
  5661. accesses by calling the `__dpmi_lock_linear_region' library function.  This
  5662. also means in practice that you should write your handler in assembly, as
  5663. described in how to set an interrupt handler in Section 18.9, above.  You can
  5664. disable virtual memory, or put `_CRT0_FLAG_LOCK_MEMORY' into
  5665. `_crt0_startup_flags' to make sure nothing is paged out (but then your
  5666. program might not have enough memory to run, unless you run on
  5667. memory-abundant systems).
  5668.  
  5669. Another problem might be that the hardware peripheral you use generates a lot
  5670. of interrupts.  Due to specifics of hardware interrupts handling in protected
  5671. mode, there is a substantial overhead involved with reflection of interrupts
  5672. between real and protected modes.  For instance, on a 486DX/33 this
  5673. reflection might consume up to 3000 clocks; on a 386SX/16, even a 1KHz clock
  5674. might eat up 1/2 of available cycles.  If your hardware fires too many
  5675. interrupts, your CPU might not be able to keep up.  In that case, consider
  5676. reducing the interrupt frequency, or move some of the processing done inside
  5677. the interrupt handler to some other place.  Use a ring 0 DPMI server such as
  5678. `CWSDPR0' or `PMODE/DJ' which don't swap interrupt stacks--this will reduce
  5679. the overhead of the interrupt reflection to some degree.  If your handler is
  5680. written in C, write it in assembly and make sure it doesn't chain.  If that
  5681. doesn't help, install a real-mode handler.
  5682.  
  5683. Some losing memory managers, notably EMM386, were reported to induce a high
  5684. interrupt handling overhead.  In one case, a user reported an increase in the
  5685. interrupt rate from 2 KHz to 6 KHz after uninstalling EMM386.
  5686.  
  5687. Still another possibility is that you use a non-default `sbrk' algorithm in
  5688. your program (check if the header file `crt0.h' is included anywhere in the
  5689. program, and if so, if the `_CRT0_FLAG_UNIX_SBRK' bit in the
  5690. `_crt0_startup_flags' variable is set by the program.  If it is, then a
  5691. hardware interrupt which happens at the wrong time could crash your machine,
  5692. especially if you run under Windows 3.x.
  5693.  
  5694. You should also keep in mind that the DPMI server can decide to handle some
  5695. of the interrupts itself and not pass them to your program, although this is
  5696. rare.  For example, Win95 won't pass the Ctrl-Alt-Del combination to your
  5697. keyboard interrupt handler, but will rather act on it itself; QDPMI sometimes
  5698. processes Ctrl-C presses so that your program never sees them, etc.
  5699. Sometimes, but not always, you can change some configuration option to make
  5700. some keys get to your handler (e.g., the Alt-TAB setting on the Win3.x `.PIF'
  5701. file).
  5702.  
  5703. If the above still doesn't explain your problem, then post your code on
  5704. comp.os.msdos.djgpp news group or the djgpp mailing list <djgpp@delorie.com>,
  5705. tell there how it fails and somebody will usually have a solution or a
  5706. work-around for you.
  5707.  
  5708. 18.12 How to read and write ports
  5709. =================================
  5710.  
  5711. **Q*: I need to read from and write to PC ports, and I'm accustomed to using
  5712. the `inp' and `outp' functions.  But I hear they aren't available in DJGPP?*
  5713.  
  5714. *A* :  They are in v2.x.  Just  `#include <pc.h>'  and you get their
  5715. prototypes.  The functions themselves are in the default library.  Note that
  5716. there are also size-specific versions for byte- word- and dword-long access
  5717. (e.g., `inportl' for reading a 32-bit dword), as well as functions to
  5718. read/write sequences of bytes and words, like `inportsb' and `outportsw';
  5719. these are DJGPP-specific.
  5720.  
  5721. 18.13 Inline Assembly code with GCC
  5722. ===================================
  5723.  
  5724. **Q*: I am used to writing inline assembly with Borland C, but can't figure
  5725. out the way to do it with GCC...*
  5726.  
  5727. **Q*: How can I reference C variables from my inline assembly code?*
  5728.  
  5729. *A* :  GCC has extensive inline assembly facilities.  They allow you to
  5730. specify everything other compilers let you (like the registers where GCC will
  5731. put specific results), but in a way that doesn't disable compiler
  5732. optimizations of the C code that includes inline assembly.  Because of this
  5733. flexibility, the syntax of the inline assembly code is very different from
  5734. the other DOS-based compilers.  The GCC on-line docs describe these
  5735. facilities in detail; to read the relevant sections, type this from the DOS
  5736. prompt:
  5737.  
  5738.        info gcc "C Extensions" "Extended Asm"
  5739.  
  5740. (Note the quotes: they are important.)  You will, of course, need that the
  5741. stand-alone info reader be installed on your system for the above command to
  5742. work.  If it is not already installed, get the file `txi390b.zip' from the
  5743. DJGPP distribution and install it.
  5744.  
  5745. If you read this FAQ via WWW, you can also read about the GCC inline assembly
  5746. extensions with your Web browser, at this URL:
  5747.  
  5748.      http://www.delorie.com/gnu/docs/gcc/gcc_86.html#SEC89
  5749.  
  5750. 19. Legal Aspects
  5751. *****************
  5752.  
  5753.   This chapter answers some questions about various legal aspects of writing
  5754. programs with DJGPP.
  5755.  
  5756. 19.1 Legal (un)restrictions on DJGPP applications
  5757. =================================================
  5758.  
  5759. **Q*: Can you explain in plain English the legal restrictions of distributing
  5760. programs compiled with DJGPP?*
  5761.  
  5762. **Q*: Can I write commercial programs with DJGPP?*
  5763.  
  5764. *A* :  In most cases, you don't have to worry about any legal restrictions
  5765. when you compile your programs with DJGPP.  Using the GNU C/C++ compiler
  5766. doesn't make your programs subject to *any* restrictions.  The C library
  5767. which comes with DJGPP is *free*, which means you are free to use it in any
  5768. way you like (but please observe basic rules of courtesy in Section 19.2.)
  5769. So, if you write C programs, you have absolutely nothing to worry about.
  5770.  
  5771. The basic C++ `iostream' class library (`libiostr.a') and the Standard
  5772. Template Library (`libstdcx.a') which come with DJGPP allow you to use them
  5773. binary-wise (i.e., without changing library sources) in your C++ programs
  5774. *without restrictions*, unless you compile your programs with a compiler
  5775. other than Gcc (which won't happen if you work with DJGPP).  Only the library
  5776. of additional C++ classes (`libgpp.a') requires that you provide your
  5777. customers with source or object code of the application, so they could relink
  5778. the application with future or modified versions of the C++ library.  (If you
  5779. intend to distribute commercial programs linked with the `libgpp.a' library,
  5780. you are strongly advised to read the GNU Library General Public License which
  5781. comes with the library, for rigorous definition of its terms.)
  5782.  
  5783. Two GNU packages, `Flex' and `Bison', are also special in that using them to
  5784. produce your programs doesn't place your programs under GPL or LGPL.  In
  5785. other words, lexers produced by `Flex' and parsers produced by `Bison' do
  5786. *not* imply GPL/LGPL.
  5787.  
  5788. If you *do* use in your program any of the FSF sources that fall under
  5789. GPL/LGPL (like some of the GCC's sources, or the GNU `getopt' or `regex'
  5790. packages which come with many GNU programs), then you must comply with the
  5791. terms of GNU licenses when distributing your programs; in this case your
  5792. entire application becomes GPL.  If that is unacceptable to you, consider
  5793. using the versions of `regex' and `getopt' from the DJGPP C library (which
  5794. are not as powerful, but are free from any restrictions).
  5795.  
  5796. You may ship any of the utilities developed specifically for DJGPP (e.g., the
  5797. floating-point emulator or the CWSDPMI DPMI host) *as distributed by DJ
  5798. Delorie* with your program with no other requirement besides telling your
  5799. customers how to get DJGPP for themselves.
  5800.  
  5801. Note that the above says nothing about the legal aspects of contributed
  5802. packages, like `GRX' and others; you will need to read their docs to find out.
  5803.  
  5804. 19.2 Legal restrictions of DJGPP utilities and libraries
  5805. ========================================================
  5806.  
  5807. **Q*: Can I redistribute djgpp, and if so, how?*
  5808.  
  5809. **Q*: I run a business that sells shareware for distribution costs.  Can I
  5810. include djgpp on my CD-ROM?*
  5811.  
  5812. **Q*: I want to include djgpp in a product that happens to need a compiler
  5813. provided with it.  Can I do this?*
  5814.  
  5815. **Q*: Is DJGPP GNU software?*
  5816.  
  5817. **Q*: Is DJGPP public domain software?*
  5818.  
  5819. **Q*: Is DJGPP shareware?*
  5820.  
  5821. *A* :  DJGPP is *not* public domain, neither is it shareware (you *don't*
  5822. have to pay a license fee to use DJGPP).  Parts of DJGPP (the compiler and
  5823. some of the development tools) *are* GNU software, so you must comply with
  5824. GNU GPL if you distribute those parts (usually, you won't need to distribute
  5825. them, because they are freely available to everyone).  A small part of the C
  5826. library is taken from the Berkeley BSD sources, and is therefore in public
  5827. domain.  Other parts of DJGPP, which include most of the C library, the free
  5828. DPMI host CWSDPMI, and some of the utilities, are copyrighted, but in a way
  5829. that allows you to use them freely and without restrictions.
  5830.  
  5831. When you redistribute DJGPP itself (as opposed to your programs compiled with
  5832. DJGPP), you must comply to the conditions applicable to whatever you
  5833. distribute.  The parts which are in public domain are, of course, freely
  5834. distributable.  Other parts of DJGPP fall under the DJGPP copyright which
  5835. allows you to redistribute everything provided that you follow these rules:
  5836.  
  5837.    * You must redistribute DJGPP as a whole, with all its parts, including
  5838.      the sources to utilities and libraries that are part of DJGPP, unless
  5839.      other arrangements are first made with DJ Delorie <dj@delorie.com>.
  5840.  
  5841.    * Please make a good faith effort to stay up to date with the latest DJGPP
  5842.      versions, so people don't get old versions with bugs that are long ago
  5843.      solved, or, worse still, versions that are no longer supported.
  5844.  
  5845.    * You must call it *DJGPP* and nothing else.
  5846.  
  5847.    * You may *not* take credit for it, and you must *not* remove any notices
  5848.      in DJGPP that give credit to those who worked on it.
  5849.  
  5850.    * You must tell the recipient how to get the latest version off the
  5851.      Internet, or at least how to find out what the latest version is.
  5852.      DJ Delorie gets a lot of questions from people who got old versions from
  5853.      vendors and don't realize that they're way out of date.
  5854.  
  5855.    * Distributing CWSDPMI with shareware or commercial programs requires
  5856.      notification of its author Charles Sandmann <sandmann@clio.rice.edu> by
  5857.      mail or acknowledged e-mail.
  5858.  
  5859. In addition, it would be a courtesy to inform DJ Delorie <dj@delorie.com>
  5860. that you are including DJGPP in your product, in case this information is
  5861. obsolete.  A token sample of your distribution would be nice also.
  5862.  
  5863. 20. Getting Help
  5864. ****************
  5865.  
  5866.   This chapter tells you how to get answers to questions you didn't find in
  5867. this FAQ.
  5868.  
  5869. 20.1 Don't post DJGPP-specific problems to GNU News groups
  5870. ==========================================================
  5871.  
  5872. **Q*: I post my problem to the "help-gcc" News group, but don't get any
  5873. answers.*
  5874.  
  5875. *A* :  Is your problem likely to be special to the DJGPP port or to the DOS
  5876. environment?  If so, don't post to GNU Usenet groups, but to the
  5877. comp.os.msdos.djgpp news group or to the DJGPP mailing list
  5878. <djgpp@delorie.com>.  People who read GNU News groups usually neither know
  5879. nor care about DOS-specific problems.  Post there only if the problem seems
  5880. to be generic to one of the FSF utilities.  For most problems, this can be
  5881. deduced only after either tracing a problem in the source code or testing it
  5882. on some non-DOS platform.  As a general rule, always post to the DJGPP group
  5883. first.
  5884.  
  5885. 20.2 How to post to the mailing list
  5886. ====================================
  5887.  
  5888. **Q*: How do I post to the DJGPP mailing list?*
  5889.  
  5890. *A* :  Send mail to the list address <djgpp@delorie.com> as if it were a
  5891. person.  Please use the mailing list only if you cannot access the DJGPP news
  5892. group, because reflecting the mail to and from the mailing lists incurs
  5893. additional load on the DJGPP server.
  5894.  
  5895. 20.3 How to become a subscriber to the mailing list
  5896. ===================================================
  5897.  
  5898. **Q*: How do I subscribe to the DJGPP mailing list?*
  5899.  
  5900. *A* :  Send mail to the list server <listserv@delorie.com> (NOT to djgpp@!!),
  5901. leave the subject line empty and in the body write:
  5902.  
  5903.       subscribe <your e-mail address> djgpp
  5904.  
  5905. If you only want to receive announcements of new versions and ported
  5906. software, but don't want to see any other DJGPP mail traffic, subscribe to
  5907. the `djgpp-announce' by sending message to the list server
  5908. <listserv@delorie.com> which says so:
  5909.  
  5910.       subscribe <your e-mail address> djgpp-announce
  5911.  
  5912. The announcements which go to `djgpp-announce' get reflected to `djgpp', so
  5913. you don't need to subscribe to both these lists.
  5914.  
  5915. The DJGPP mailing list is available in the daily and weekly digest forms.  To
  5916. subscribe to one of these, send this one-line message to the above list
  5917. server:
  5918.  
  5919.       subscribe <your e-mail address> djgpp-digest-daily
  5920.  
  5921. or
  5922.  
  5923.       subscribe <your e-mail address> djgpp-digest-weekly
  5924.  
  5925. Note that some mailers reject messages with too large size, so you might have
  5926. trouble with the weekly digest.  If you subscribe to it and don't get the
  5927. digest, try the daily one instead, or switch to another mail software.
  5928.  
  5929. You can also subscribe to DJGPP-related mailing lists through DJ Delorie's
  5930. WWW server, at this URL:
  5931.  
  5932.      http://www.delorie.com/mailing-lists/subscribe.html
  5933.  
  5934. Note that you don't have to subscribe to the djgpp mailing list if you don't
  5935. want to get all the traffic in your mailbox (typically, about 30 messages per
  5936. day).  You can ask questions on the list even if you are not a subscriber,
  5937. because people usually answer both to your e-mail address and to the list
  5938. (well, actually, the mailer program does it automatically and most people
  5939. don't bother to change that).  If you want to be sure the mail gets to you
  5940. directly, say in your message that you don't subscribe to the list, and ask
  5941. people to answer directly.
  5942.  
  5943. If you have a Usenet feed, consider reading the comp.os.msdos.djgpp news
  5944. group instead of subscribing to the mailing list, so that the load on DJ's
  5945. list server will get lower.  There is also a possibility of reading the news
  5946. group (but not posting to it) through the Mercury Gopher server at Michigan
  5947. State University,
  5948. gopher://gopher.msu.edu:3441/chronological%20comp.os.msdos.djgpp
  5949.  
  5950. 20.4 How to unsubscribe from the mailing list
  5951. =============================================
  5952.  
  5953. **Q*: Whew!  There's too much traffic on the djgpp mailing list (at least the
  5954. SysAdmin glaring over my shoulder thinks so... ;-).  How do I unsubscribe
  5955. myself?*
  5956.  
  5957. **Q*: I've been trying for days to unsubscribe from the djgpp mailing list.
  5958. What am I doing wrong?*
  5959.  
  5960. *A* :  You should be sending your unsubscribe messages to the list server
  5961. <listserv@delorie.com> *(not djgpp@delorie.com!),* with the contents being
  5962. just this:
  5963.  
  5964.       unsubscribe <your e-mail address> djgpp
  5965.  
  5966. When you unsubscribe, that stops *new* messages from being sent to you.
  5967. Messages that are already in the mail queues of various mail programs between
  5968. the DJGPP list server and the machine where you receive your mail--cannot be
  5969. stopped.  Therefore, allow some time before you decide that your unsubscribe
  5970. message didn't work.  In extreme cases, when one of the machines that are
  5971. forwarding mail to you is down, you can get the messages upto 5 days after
  5972. you've unsubscribed.
  5973.  
  5974. If you think you have waited enough and the messages still keep coming, write
  5975. to listserv administrator <djgpp-request@delorie.com> and ask him to help you.
  5976.  
  5977. You can also unsubscribe yourself from any of the DJGPP-related mailing lists
  5978. through DJ Delorie's WWW server, at this URL:
  5979.  
  5980.      http://www.delorie.com/djgpp/mailing-lists/subscribe.html
  5981.  
  5982. Recently, DJ has added a mail archive browser to his Web site.  With this
  5983. tool, you can list and read the messages by year, month and day, as well as
  5984. search the last few days for something you might have missed.  This service
  5985. is available via World-Wide Web, at this URL:
  5986.  
  5987.      http://www.delorie.com/djgpp/mail-archives/browse.cgi
  5988.  
  5989. 20.5 If you don't see any message from the list ...
  5990. ===================================================
  5991.  
  5992. **Q*: I don't get any messages from the DJGPP list for several days.  Is the
  5993. list alive?*
  5994.  
  5995. *A* : Try sending a message to the list and see if you get it back.  If not,
  5996. it is possible that your name was inadvertently taken off the list.  This is
  5997. known to happen sometimes (don't ask me how).  Also, if your address begins
  5998. to fail consistently (like "user unknown" or "unknown host"), DJ Delorie
  5999. removes that address from the list, but cannot send a message to this effect,
  6000. for obvious reasons.  You can check if you are subscribed to any of the
  6001. DJGPP-related mailing lists through DJ Delorie's WWW server, at this URL:
  6002.  
  6003.      http://www.delorie.com/djgpp/mailing-lists/subscribe.html
  6004.  
  6005. If this tells you you're not, re-subscribe yourself by sending the above
  6006. subscription message to listserv <listserv@delorie.com>, or via DJ's server,
  6007. at this URL:
  6008.  
  6009.      http://www.delorie.com/djgpp/mailing-lists/subscribe.html
  6010.  
  6011. When in doubt, re-subscribe anyway (it hurts neither you, nor the list
  6012. server).
  6013.  
  6014. If you subscribe to the weekly digest, then the problem might be that your
  6015. mailer rejects the huge message size.  Try the daily digest, or switch to
  6016. another mailer, and see if that helps.
  6017.  
  6018. 20.6 Why do I get every message more than once?
  6019. ===============================================
  6020.  
  6021. **Q*: Why am I getting 2 and often more copies of the same message?  Don't
  6022. you people think I can get the idea at the first reading??*
  6023.  
  6024. *A* :  First, check the headers to make sure that all of the duplicate
  6025. messages have their `To:' header addressed to the DJGPP list, not to your
  6026. direct e-mail address.  Often, when people reply to your post, you get the
  6027. direct message, and a `Cc:' (the "carbon copy") one via djgpp list server.
  6028. This is normal behavior.
  6029.  
  6030. If indeed you get more than one copy of a message addressed to the list, it
  6031. is possible that you have added yourself to the list several times.  (This
  6032. could happen if your site supports a mail exploder which re-mails DJGPP to
  6033. you, and you have also subscribed yourself directly.)  One way to check this
  6034. would be to unsubscribe and see if you keep getting mail.  Another way is to
  6035. check your subscription through DJ's server, at this URL:
  6036.  
  6037.      http://www.delorie.com/djgpp/mailing-lists/subscribe.html
  6038.  
  6039. Look out for multiple subscriptions, possibly under different
  6040. names/addresses.  You could also write to DJ Delorie <dj@delorie.com>, and
  6041. ask him to investigate.
  6042.  
  6043. Another thing to do, especially if you think it's not your fault, is to write
  6044. to a user named POSTMASTER at the address of each of the machines whose names
  6045. you find in the `Received:' headers of the bouncing messages (these are
  6046. people responsible for the operation of the mail software at their sites) and
  6047. ask them politely to help.
  6048.  
  6049. Many times this kind of problem is caused by excessive load on the list
  6050. server, so everybody who can please switch to reading the comp.os.msdos.djgpp
  6051. news group and unsubscribe from the list.
  6052.  
  6053. 20.7 DJGPP now has a news group!
  6054. ================================
  6055.  
  6056. **Q*: With so much daily traffic (about 30 messages a day), isn't it high
  6057. time to create a Usenet News group?*
  6058.  
  6059. *A* :  Beginning June 1st, 1995, DJGPP *has* its News group!  It is called
  6060. *comp.os.msdos.djgpp*, and it is two-way gated to the venerable DJGPP mailing
  6061. list.  This means messages posted to either the mailing list or the news
  6062. group will appear on both (once, let's hope ;-); you can read either one and
  6063. post to either one, and everybody eventually sees everything.  The entire
  6064. traffic ends up in the mail archives on the DJ's Web server within 24 hours,
  6065. and is available for searching, at this URL:
  6066.  
  6067.      http://www.delorie.com/djgpp/mail-archives/
  6068.  
  6069. If you have a Usenet feed, now is the time to consider unsubscribing from the
  6070. mailing list and switch to reading the news group instead, so that the load
  6071. on the list server will get lower.
  6072.  
  6073. 21. Version 2 vs v1.x
  6074. *********************
  6075.  
  6076.   This chapter is for those who are used to working with DJGPP v1.x and want to
  6077. know more about v2 while they consider switching.
  6078.  
  6079. 21.1 New features in DJGPP v2
  6080. =============================
  6081.  
  6082. **Q*: What exciting new features will I find in v2 as opposed to v1.x?*
  6083.  
  6084. *A* :  DJGPP v2.x is a DPMI-only environment, and it includes a free DPMI
  6085. host for those who don't have another DPMI provider installed.  In addition,
  6086. v2 features the following major improvements upon v1.1x:
  6087.  
  6088.    * much faster extender (the free DPMI host) and library functions;
  6089.  
  6090.    * very low memory footprint of the DPMI host below 640KB;
  6091.  
  6092.    * the DPMI server is loaded only once: no more problems with spawning child
  6093.      programs (e.g., almost unlimited recursive Make's);
  6094.  
  6095.    * ANSI- and POSIX-compliant libraries and header files, which should make
  6096.      porting Unix programs a lot easier;
  6097.  
  6098.    * support for signals;
  6099.  
  6100.    * 387 emulation under DPMI;
  6101.  
  6102.    * graphics which works in *any* setup, including under Windows;
  6103.  
  6104.    * fixes of many bugs in hardware interrupts' and mixed-mode programming
  6105.      support;
  6106.  
  6107.    * support of long filenames on Windows 95;
  6108.  
  6109.    * ability to build all of DJGPP without commercial products (like Turbo C
  6110.      required to compile go32 in v1.x);
  6111.  
  6112. If you want to help in further v2 development, check out the list of features
  6113. which have yet to be done and volunteer to implement some of them.
  6114.  
  6115. 21.2 DJGPP environment in v2.x
  6116. ==============================
  6117.  
  6118. **Q*: There's been this talk about v2 and about `go32' going away in that
  6119. version, but I'm confused on what the new setup will be.  Could you clarify
  6120. the details of this change?*
  6121.  
  6122. *A* :  In v1.x of DJGPP, the `go32' extender was responsible for the
  6123. following:
  6124.  
  6125.    * Loading and running the application in protected mode.
  6126.  
  6127.    * Managing protected-mode and virtual memory.
  6128.  
  6129.    * "Extending DOS" so that protected-mode programs could issue calls to
  6130.      real-mode DOS and BIOS services and still run.  (This is mostly done by
  6131.      switching to real mode and reissuing the interrupt, but some services
  6132.      require special handling by the extender.)
  6133.  
  6134.    * Handling of hardware interrupts which happen while the CPU is in
  6135.      protected mode.
  6136.  
  6137.    * Loading 387 emulator (if required).
  6138.  
  6139.    * Loading the graphics driver and working with VGA bank-switching to create
  6140.      an illusion of a linear video memory.
  6141.  
  6142.    * Command-line and wild-card expansion in a Unix-like fashion.
  6143.  
  6144. In v2.x, a minority of these functions are done by a DPMI host, which is a
  6145. memory-resident software required to run protected-mode programs under
  6146. MS-DOS.  There are a few commercial DPMI hosts (like Quarterdeck's `QDPMI',
  6147. Qualitas `386Max', MS-Windows 3.x and Win95, OS/2, even Linux), but DJGPP v2
  6148. comes with a free DPMI host called `CWSDPMI' for those who don't have one
  6149. already.  Loading the application into protected-mode memory (a function done
  6150. in v1.x by `go32') is handled by a 2KB-long real-mode stub which runs at
  6151. start-up, before the application's `main' functions is called (the stub will
  6152. also load `CWSDPMI' if no other DPMI host is detected).  All the other custom
  6153. code required to process BIOS- and DOS-related calls from protected-mode is
  6154. now built into the library functions which your program calls, so there is no
  6155. need for a special extender, because the application just issues DPMI calls
  6156. serviced by the DPMI host.
  6157.  
  6158. `CWSDPMI' can be loaded as a TSR, even loaded `HIGH' into the HMA/UMB, which
  6159. will make applications load much faster.
  6160.  
  6161. 22. Miscellany
  6162. **************
  6163.  
  6164.   This chapter is a hodgepodge of questions which don't belong to any of the
  6165. other chapters.
  6166.  
  6167. 22.1 How to change a DJGPP package?
  6168. ===================================
  6169.  
  6170. **Q*: I want to change cc1.  How do I do this?*
  6171.  
  6172. **Q*: How do I fix a bug/add a feature to one of the DJGPP programs?*
  6173.  
  6174. *A* :  First, get the sources.  These are called `*s.zip' in the DJGPP
  6175. distribution.  The C Library sources are in `djlsr201.zip'.  Some sources are
  6176. too big, and might be split into multiple zips, all of which must be unzipped
  6177. to get a complete source distribution, like this:
  6178.  
  6179. `em1934s1.zip'
  6180. `em1934s2.zip'
  6181. `em1934s3.zip'
  6182. All sources are shipped in ready-to-build form.  Any diffs that come with the
  6183. source distribution, like the files in the `diffs/' directory, have already
  6184. been applied, and any configuration scripts and/or batch files have been run.
  6185.  
  6186. Next, try to build the program without changing it.  Some packages will have
  6187. a `CONFIGUR.BAT' file; if so, run it first.  If there is a `MAKE.BAT' file,
  6188. run it; if not, look for a file named `MAKEFILE.DJ' or `MAKEFILE.DJG';
  6189. sometimes these will be in a subdirectory called `dos/', or `msdos/', or
  6190. `pc/.'  If there is such a file, then type, e.g., `make -f makefile.djg', if
  6191. not, just say `make' and see what happens.  (The reason for an apparent lack
  6192. of a standard here is that different packages were ported to DJGPP by
  6193. different people, as best as they saw fit.)  After you've successfully built
  6194. the program, make your fixes and build the program the same way you did
  6195. before.
  6196.  
  6197. Note that generally to build these programs, you must have the GNU Make
  6198. program, e.g.
  6199. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/mak375b.zip, and some
  6200. makefiles require that you install additional utilities, like Sed
  6201. ftp.simtel.net/pub/simtelnet/gnu/djgpp/sed118b.zip, e.g. ftp://.  Sometimes
  6202. the makefiles won't even run under `COMMAND.COM' (they require a smarter
  6203. shell).  In that case, either get a better shell, or convert the makefile to
  6204. be runnable by `COMMAND', or do the required steps manually.  If the Makefile
  6205. is too complex for you and you can't figure out what are the necessary
  6206. commands, invoke make with `-n' switch and see what it would have done.
  6207.  
  6208. If your machine lacks floating-point hardware (like a 386 without a 387, or a
  6209. 486SX), then you should know that current versions of GNU Sed and GNU Make
  6210. issue floating point instructions, so you will have to make provisions for
  6211. loading an emulator, see above, FP Emulation in Section 11.1.  The port of
  6212. Make 3.75 and later can be built so that it doesn't issue FP instructions,
  6213. but you will have to get the sources and recompile Make first, as the stock
  6214. version wasn't configured in that way.
  6215.  
  6216. If you think that you found a bug in one of the programs or libraries written
  6217. for DJGPP (e.g. the C library, CWSDPMI, symify, etc.) be sure to check the
  6218. list of known bugs, at this URL:
  6219.  
  6220.      http://www.delorie.com/djgpp/doc/kb/kb_7.html#SEC4
  6221.  
  6222. If your bug is not there, you can later submit it to the bug-tracking system,
  6223. at this URL:
  6224.  
  6225.      http://www.delorie.com/djgpp/bugs/
  6226.  
  6227. Before you submit a bug report, please make every effort to verify that your
  6228. bug is not caused by incorrect usage, or by problems in your DJGPP
  6229. installation.  Reports such as "All DJGPP programs crash" or "I cannot
  6230. compile any program" are clearly not bugs, because these things work for many
  6231. hundreds of DJGPP users every day.  If you can investigate the cause of the
  6232. bug and find a solution that makes it go away, submit a bug report with all
  6233. the details.  If you cannot find the cause(s), I suggest posting your problem
  6234. description to the news group and asking people to verify that it is indeed a
  6235. bug, before you submit a bug report.  The bug-tracking system includes a list
  6236. of all known bugs, many of them with solutions or work-arounds; please check
  6237. them before creating a new bug report.
  6238.  
  6239. 22.2 Where to find sample DJGPP code or a package ported to DJGPP?
  6240. ==================================================================
  6241.  
  6242. **Q*: Where can I find an example of XXXX / a package doing YYYY ?*
  6243.  
  6244. *A* :  Stephen Turnbull <turnbull@shako.sk.tsukuba.ac.jp> has compiled a list
  6245. of publicly available packages related to DJGPP, based on the DJGPP mailing
  6246. list traffic.  The list is still under construction (Steve says that many
  6247. pointers have not been followed up to get host and directory references
  6248. right), so it must be taken with a grain of salt.  Check out Steve's list, at
  6249. this URL:
  6250.  
  6251.      http://turnbull.sk.tsukuba.ac.jp/public-ftp/djgpp/doc/documentation.list.html
  6252.  
  6253. Here is a list of places you might look into for examples of frequently
  6254. needed code fragments, or for packages people keep asking about:
  6255.  
  6256.    * Interrupt-driven support of peripheral devices and hooking hardware
  6257.      interrupts:
  6258.  
  6259.         - Alaric B. Williams <alaric@abwillms.demon.co.uk> maintains a
  6260.           library of utility functions and example handlers, useful for
  6261.           writing hardware interrupt handling code.  You can get Alaric's
  6262.           library with your Web browser, at this URL:
  6263.  
  6264.                http://www.abwillms.demon.co.uk/prog/index.html
  6265.  
  6266.         - Bill Currie <bill_currie@MAIL.TAIT.CO.NZ> has written sample code
  6267.           for hardware interrupt handlers, e.g.
  6268.  
  6269.  
  6270.  
  6271.  
  6272.           ftp://ftp.delorie.com/pub/djgpp/contrib/sample-interrupt-handlers-v2.zip
  6273.           which should get you off the ground if you need to write your own
  6274.           handlers.
  6275.  
  6276.         - Martynas Kunigelis <martynas.kunigelis@vm.ktu.lt> donated a
  6277.           tutorial and a working code that installs a keyboard interrupt
  6278.           handler, e.g.
  6279.           ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2tk/mkkbd3.zip that
  6280.           can also serve as a good example of a hardware interrupt handler.
  6281.  
  6282.         - you can look at the latest version of Sound Blaster support library
  6283.           at the Oulu repository, e.g.
  6284.           ftp://x2ftp.oulu.fi/pub/msdos/programming/djgpp2/sb05_dj2.zip or at
  6285.           the DJGPP server, e.g.
  6286.           ftp://ftp.delorie.com/pub/djgpp/contrib/sb05_dj2.zip; this package
  6287.           is maintained by Joel Hunter <jhunter@kendaco.telebyte.net>.
  6288.  
  6289.         - check out the example of hooking the timer interrupt, e.g.
  6290.           ftp://ftp.coast.net/Coast/msdos/c/pctime13.zip.
  6291.  
  6292.         - if you need a serial communications library, check out SVAsync,
  6293.           e.g. ftp://ftp.delorie.com/pub/djgpp/contrib/svasync.zip.
  6294.  
  6295.    * Network support libraries:
  6296.  
  6297.         - the TCPLIB library, e.g.
  6298.           ftp://lab1.psy.univie.ac.at/pub/tcplib-dj200/tcplib-dj200.1.tar.gz
  6299.           provides the TCP/IP sockets interface.  (I am told that you can
  6300.           safely ignore the warnings you get when compiling the package.)
  6301.  
  6302.         - a port of WATTCP library, e.g.
  6303.           ftp://ftp.msen.com/pub/vendor/snsi/wattcp/gnu-c/.
  6304.  
  6305.         - a modified port of WATTCP library done by DJ Delorie
  6306.           <dj@delorie.com> is available from DJ's server, e.g.
  6307.           ftp://ftp.delorie.com/pub/djgpp/dj/.
  6308.  
  6309.    * Port of curses library to DJGPP:
  6310.  
  6311.         - download PDCurses package, e.g.
  6312.           ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2tk/pdc22.zip.
  6313.  
  6314.    * Dynamically loaded code:
  6315.  
  6316.         - Check out the DLM (Dynamic Link Modules) environment for DJGPP,
  6317.           written by "Ilya P. Ryzhenkov" <ilya@spy.isp.nsc.ru>, available from
  6318.           his machine, e.g. ftp://spy.isp.nsc.ru/sys/pub/dlm/.
  6319.  
  6320.    * X library:
  6321.  
  6322.         - the Xlibemu library, e.g. ftp://asterix.inescn.pt/pub/PC/X/ includes
  6323.           `Xt' and `Xmu' toolkits, a 3D version of the `AW' toolkit, a few
  6324.           demo applications (e.g. `xmine'), and can be used to compile
  6325.           `Tcl'/`Tk' and GNU Emacs with X support.  Xlibemu is based on X11R5
  6326.           and was developed by Antonio Costa <acc@asterix.inescn.pt> for
  6327.           DJGPP v1.x.  It is also available on an alternative site, e.g.
  6328.           ftp://groucho.idt-isep.ipp.pt/pub/pc/djgpp/etc/X/ and on the DJGPP
  6329.           server, e.g. ftp://ftp.delorie.com/pub/djgpp/contrib/Xlibemu/.
  6330.  
  6331.         - the Xlib and Xt for DV/X environment, e.g.
  6332.           ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v1tk/qddvx102.zip (you
  6333.           will also need qdlib102.zip and qdtkt102.zip from the same site).
  6334.  
  6335.    * Ports of various GNU utilities not included in DJGPP:
  6336.  
  6337.         - Many of these are now part of DJGPP, so first look on SimTel.NET
  6338.           mirrors with the rest of DJGPP, e.g.
  6339.           ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/.
  6340.  
  6341.         - Marc Singer <elf@netcom.com> maintains a port of RCS, the Revision
  6342.           Control System, to DJGPP, e.g.
  6343.           ftp://ftp.netcom.com/pub/el/elf/rcsdos/.
  6344.  
  6345.    * GUI libraries:
  6346.  
  6347.         - SWORD (the System of Windows for the ORganization of the Desktop)
  6348.           is a Graphic User Interface library made with C++ objects, written
  6349.           and maintained by Eric Nicolas <nicolas@JUPITER.saclay.cea.fr>.  The
  6350.           latest version 2.1 is available from the DJGPP v2tk subdirectory,
  6351.           e.g. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2tk/ as
  6352.           sw21_*.zip.
  6353.  
  6354.         - check out the BCGUI package, at this URL:
  6355.  
  6356.                http://www.delorie.com/djgpp/dl/contrib/
  6357.  
  6358.           or get BCGUI via FTP, e.g.
  6359.           ftp://ftp.delorie.com/pub/djgpp/contrib/bcguiNNN.zip or get BCGUI
  6360.           at Stephen Turnbull's server, e.g.
  6361.           ftp://turnbull.sk.tsukuba.ac.jp/pub/djgpp/packages/bcguiNNN.zip.
  6362.  
  6363.         - If you actually have the original Borland Turbo Vision, then you
  6364.           might want to get patches to compile Turbo Vision under DJGPP, e.g.
  6365.           ftp://ftp.uni-stuttgart.de/pub/systems/os2/programming/support/.
  6366.           For more info on this port, visit the TVPlus site, at this URL:
  6367.  
  6368.                http://www.zeta.org.au/~grove/tvhome.html
  6369.  
  6370.         - Another port of Turbo Vision library was done by Robert Hoehne
  6371.           <Robert.Hoehne@Mathematik.TU-Chemnitz.DE>, and can be downloaded
  6372.           via WWW, at this URL:
  6373.  
  6374.                http://www.tu-chemnitz.de/~rho/tvision.html
  6375.  
  6376.           , and also from the DJGPP distribution sites, e.g.
  6377.           ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2tk/tvisionb.zip
  6378.  
  6379.    * Game programming:
  6380.  
  6381.         - Try the Jlib gaming/graphics library, e.g.
  6382.           ftp://x2ftp.oulu.fi/pub/msdos/programming/djgpp2/jlib_NNN.zip
  6383.           written by J P Griffiths <jpg@cs.waikato.ac.nz>.  This library is
  6384.           best suited to multi-platform game programming, since it's portable
  6385.           to Linux.
  6386.  
  6387.         - Also see the Allegro game programming library, e.g.
  6388.           ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2tk/alleg211.zip,
  6389.           written by Shawn Hargreaves <Shawn@talula.demon.co.uk>.  It is also
  6390.           available from the Allegro home page, at this URL:
  6391.  
  6392.                http://www.talula.demon.co.uk/allegro/
  6393.  
  6394.             This library is best suited to DOS game programming.
  6395.  
  6396.    * VGA Mode-X graphics:
  6397.  
  6398.         - Paul Fenwick <bg914@FreeNet.Carleton.CA> wrote an X-Mode package
  6399.           Xlib, e.g. ftp://ftp.delorie.com/pub/djgpp/contrib/xlibdj24.zip or
  6400.           Xlib at Oulu, e.g.
  6401.           ftp://x2ftp.oulu.fi/pub/msdos/programming/djgpp2/xlibdj24.zip.
  6402.  
  6403.    * Multi-tasking libraries:
  6404.  
  6405.         - The POSIX Pthreads library, e.g.
  6406.           ftp://ftp.cs.fsu.edu/pub/PART/PTHREADS/pthreads.zip is a portable,
  6407.           standard package supported on many platforms.
  6408.  
  6409. 22.3 How to create symbolic links to programs
  6410. =============================================
  6411.  
  6412. **Q*: How do I create symbolic links?*
  6413.  
  6414. **Q*: I have this program that behaves differently depending on the name it's
  6415. called.  Under Unix, I just create symbolic links to achieve that, but DOS
  6416. doesn't support links.  Do I have to put several identical programs under
  6417. different names on my disk??*
  6418.  
  6419. *A* :  DJGPP allows you to simulate symbolic links to programs.  Generate a
  6420. stub (which is a small DOS program attached to every DJGPP program by the
  6421. `stubify.exe' program), call it by the name of the link you want, then edit
  6422. its header to run another program.  For example, let's say the real program
  6423. is `dj1.exe' and we want to make a link called `dj2.exe' that really calls
  6424. `dj1.exe.'  First, generate a stub under the name `dj2.exe.'  Next, run
  6425. `STUBEDIT' to modify the new program's stub info block and change the name of
  6426. the executable it runs.  In this case, we'd change it to `dj1':
  6427.  
  6428.       C:\USR\BIN> stubify -g dj2.exe
  6429.       C:\USR\BIN> stubedit dj2.exe runfile=dj1
  6430.  
  6431. Voila!  Now, when you run `dj2', it tells the stub to load the image of
  6432. `dj1', but pass "dj2" in `argv[0].'
  6433.  
  6434. If you use the DJGPP port of GNU Fileutils 3.13 or later, the `ln' program
  6435. there can do the above steps for you if you say this (like on Unix):
  6436.  
  6437.       ln -s dj1.exe dj2.exe
  6438.  
  6439. 22.4 Where to find the DPMI specification?
  6440. ==========================================
  6441.  
  6442. **Q*: Where can I find the specifications for the DPMI functions?*
  6443.  
  6444. *A* :  You can find the DPMI 0.9 spec by anonymous ftp to one of the
  6445. following sites:
  6446.  
  6447. At the Quarterdeck ftp site, e.g. ftp://qdeck.com/pub/memory/dpmispec.zip.
  6448.  
  6449. At the Oulu repository of PC-specific programming info, e.g.
  6450. ftp://x2ftp.oulu.fi/pub/msdos/programming/specs/dpmispec.arj.
  6451.  
  6452. The DPMI 1.0 specs are available by anonymous ftp from the Intel anonymous
  6453. ftp site, e.g. ftp://ftp.intel.com/pub/IAL/software_specs/dpmiv1.txt.  (The
  6454. file `dpmip1.zip' at the same location is the PostScript version of this
  6455. spec.)
  6456.  
  6457. Some information about the DPMI API is also found in the Ralf Brown's
  6458. Interrupt List, e.g.
  6459. ftp://ftp.simtel.net/pub/simtelnet/msdos/info/inter53c.zip.  Look at the
  6460. functions of Interrupt 31h, or search the files for the word `DPMI.'
  6461.  
  6462. You can also browse the DPMI spec on-line, at this URL:
  6463.  
  6464.      http://www.delorie.com/djgpp/doc/dpmi/
  6465.  
  6466. 22.5 The DJGPP Web site.
  6467. ========================
  6468.  
  6469. **Q*: Where is the DJGPP Web site?*
  6470.  
  6471. *A* :  Yes, DJGPP has its own home on the Internet, set up and maintained by
  6472. (who else?) DJ Delorie <dj@delorie.com>.  It has an HTML version of this FAQ
  6473. list with search capabilities, the entire set of DJGPP distribution files, a
  6474. searchable archive of the DJGPP mailing list and news group traffic, plus
  6475. other useful and interesting information about DJGPP.  For instance, did you
  6476. ever wonder how DJGPP got started and what DJ's original goals were?
  6477. Rejoice: the Web site includes the story of DJGPP genesis, at this URL:
  6478.  
  6479.      http://www.delorie.com/djgpp/history.html
  6480.  
  6481. To visit, point your Web browser to the DJGPP Web site, at this URL:
  6482.  
  6483.      http://www.delorie.com/djgpp/
  6484.  
  6485. 22.6 Where to upload your contributions to DJGPP
  6486. ================================================
  6487.  
  6488. **Q*: I wrote a program using DJGPP.  How can I make it available to others?*
  6489.  
  6490. **Q*: I found and corrected a bug in one of the programs distributed with
  6491. DJGPP.  Where should I put it?*
  6492.  
  6493. *A* :  If the program/patches are small enough, consider posting it to the
  6494. mailing list or the comp.os.msdos.djgpp news group as uuencoded compressed
  6495. archive (to conserve space).
  6496.  
  6497. If the compressed file is larger than, say, 50K bytes, it's best to upload it
  6498. to a public site where everybody can get it.  You can upload your
  6499. contribution to a special directory on the DJ Delorie's FTP server, e.g.
  6500. ftp://ftp.delorie.com/incoming/.  This directory is write-only, and it gets
  6501. purged every couple of days, so be sure to write to DJ Delorie
  6502. <dj@delorie.com> about your upload; he will then move it to the
  6503. `/pub/djgpp/contrib' directory.
  6504.  
  6505. If you decide to upload, please send mail to the `djgpp-announce' list with a
  6506. brief description of your program/patch.  (The message will get reflected to
  6507. both the news group and the DJGPP mailing list, so you don't have to
  6508. cross-post there, but it also goes to people who only subscribe to
  6509. djgpp-announce list because they want to get such announcements and nothing
  6510. else.)
  6511.  
  6512. If your program is more than a patch or a beta version, you might consider
  6513. uploading it to the DJGPP archives on SimTel.NET.  If you decide to do it,
  6514. write to DJ Delorie <dj@delorie.com> and ask him for uploading instructions.
  6515. Material uploaded there gets automatically distributed to all of the
  6516. SimTel.NET mirrors throughout the world, which makes it easier to get.
  6517.  
  6518. DJ Delorie requests that all contributed packages uploaded to his server be
  6519. source-only distributions; don't bother to include libraries or pre-compiled
  6520. binaries, since DJ deletes them when he opens the zip archive.  This is so
  6521. there will be no danger of distributing programs infected by a virus (as
  6522. there are no 32-bit virus-scanners yet).  Please avoid uploading
  6523. self-extracting archives because DJ extracts them on a Unix machine which
  6524. can't run DOS executables.
  6525.  
  6526. 22.7 DJGPP as cross-compiler
  6527. ============================
  6528.  
  6529. **Q*: I want to use DJGPP as a cross-compiler for Motorola 68K targets.  How
  6530. should I proceed about this?*
  6531.  
  6532. **Q*: I want to build GCC as a Unix-to-DOS cross-compiler.  What should I do?*
  6533.  
  6534. *A* :  If you want a cross-compiler for m68k on a DOS machine, you need DJGPP
  6535. configured as `host=i386-go32', and `target=m68k-coff.' This has been done
  6536. already, e.g. ftp://ftp.lysator.liu.se/pub/msdos/gnu/gcc-dos-m68k/.  The
  6537. binaries there are based on GCC 2.6.0.  This package is reportedly no longer
  6538. supported, but if you have questions about it, you can send them to Jim
  6539. Karpinski <jk55@cornell.edu>.  You can also try to contact Kai Ruottu
  6540. <karuottu@freenet.hut.fi>, who is the provider of DOS-hosed gcc-m68k.
  6541.  
  6542. An "RPM" (Redhat Package Maintenance) distribution of the Linux to DOS
  6543. cross-compiler is available, which is based on DJGPP v2.01 and includes
  6544. everything you need to create DJGPP binaries on Linux (without running
  6545. DOSEmu).  This package has been built by James Soutter <cgjks1@lut.ac.uk>
  6546. using the instructions below; you will need Linux and RPM 2.2.7.  The RPM
  6547. packaged cross-compiler is available from Redhat site, e.g.
  6548. ftp://ftp.redhat.com/pub/incoming/djgpp-2.1-1.i386.rpm; the sources are also
  6549. available, e.g. ftp://ftp.redhat.com/pub/incoming/djgpp-2.1-1/src.rpm.
  6550.  
  6551. For building GCC as a Unix-to-DOS cross-compiler, here are the instructions
  6552. on how to do it.  (Unfortunately, "make install" in the Gcc distribution does
  6553. exactly the wrong thing by default, so you end up copying a lot of stuff
  6554. around manually.)
  6555.  
  6556. First, use the original FSF distributions for Gcc and Binutils, not the
  6557. source distributions from DJGPP.  That's because the DJGPP archives have
  6558. sources patched to compile on MS-DOS and sometimes omit files that aren't
  6559. necessary for DJGPP.  In particular the GCC sources lack many files that the
  6560. MS-DOS build doesn't need, to conserve space.
  6561.  
  6562. Unpack Gcc and Binutils into a directory, let's call it `X/.'  Thus, you
  6563. have, say, `X/gcc-2.7.0' and `X/binutils-2.5.2.'  The following sequence of
  6564. commands should make the job:
  6565.  
  6566.      mkdir X/dos-binutils
  6567.      cd X/dos-binutils
  6568.      configure --target=i386-coff-go32
  6569.      make CFLAGS=-O
  6570.      
  6571.      mkdir -p /usr/local/i386-go32-msdos/bin
  6572.      
  6573.      cd binutils
  6574.      cp ar c++filt objcopy objdump size /usr/local/i386-go32-msdos/bin
  6575.      cp nm.new /usr/local/i386-go32-msdos/bin/nm
  6576.      cp strip.new /usr/local/i386-go32-msdos/bin/strip
  6577.      
  6578.      cd ../gas
  6579.      cp as.new /usr/local/i386-go32-msdos/bin/as
  6580.      cp gasp.new /usr/local/i386-go32-msdos/bin/gasp
  6581.      
  6582.      cd ../ld
  6583.      cp ld.new /usr/local/i386-go32-msdos/bin/ld
  6584.      
  6585.      cd ../../..
  6586.      mkdir X/dos-gcc
  6587.      cd X/dos-gcc
  6588.      configure --target=i386-go32-msdos
  6589.      # Note: this produces errors building libgcc.a.  Ignore them.
  6590.      # The libraries will come from the cross-compiler kit.
  6591.      make LANGUAGES=c CFLAGS=-O
  6592.      
  6593.      cp xgcc /usr/local/bin/gcc-dos
  6594.      cp cc1 /usr/local/i386-go32-msdos/bin/cc1
  6595.      cp cccp /usr/local/i386-go32-msdos/bin/cpp
  6596.  
  6597. Unzip the DJDev and Gcc distributions in, say, /usr/local/djgpp.  Ideally,
  6598. build libgcc.a on a DOS machine, or get it from the `djcrx200.zip' archive.
  6599.  
  6600. Remove all `^M' characters from include files (you can compile DTOU.c on the
  6601. Unix box to make this easier).  Alternatively, use the `-a' switch to UnZip
  6602. when unzipping the archives.
  6603.  
  6604. Change lib/djgpp.lnk to use "coff-i386" instead of "coff-go32" and remove the
  6605. `^M' characters from that file also.
  6606.  
  6607.      mkdir -p /usr/local/lib/gcc-lib/i386-go32-msdos/2.7.0
  6608.      cd /usr/local/lib/gcc-lib/i386-go32-msdos/2.7.0
  6609.      ln -s /usr/local/djgpp/include .
  6610.      ln -s /usr/local/djgpp/lib/* .
  6611.  
  6612. Build `stubify' and install it in `/usr/local/i386-go32-msdos/bin.'  You
  6613. might need to insert these two lines at the beginning of `stubify.c':
  6614.  
  6615.       `#include <sys/types.h>'
  6616.       `#include <unistd.h>'
  6617.  
  6618. That's it!  To build a program for DOS, say something like this:
  6619.  
  6620.       gcc-dos hello.c -o hello.exe
  6621.  
  6622. 22.8 GCC says "garbage at end of number"
  6623. ========================================
  6624.  
  6625. **Q*: There is a severe bug in GCC: it says "garbage at end of number" for
  6626. this line:*
  6627.  
  6628.       i = 0xfe+0x20;
  6629.  
  6630. *Ain't it silly that such a great compiler would fail so miserably?*
  6631.  
  6632. *A* :  That's not a bug, that's a feature of the *ANSI C language
  6633. definition.*  By ANSI rules, the above expression is a single "preprocessing
  6634. token", unless you place whitespace in front of the plus sign.  The reason
  6635. for this seemingly counterintuitive feature is the syntax of floating-point
  6636. constants in which letters `e' and `E' followed immediately by a sign signal
  6637. a decimal exponent.  You can use the `-traditional' compiler switch to turn
  6638. this feature off (together with a plethora of other ANSI features; see the
  6639. GCC docs for details).
  6640.  
  6641. 22.9 What should sizeof (struct xyzzy) return?
  6642. ==============================================
  6643.  
  6644. **Q*: When I call `sizeof' on a struct, I sometimes get values which are
  6645. larger than the sum of the sizes of the struct fields, whereas in Borland C++
  6646. I always get the correct result.  Is it a bug in GCC?*
  6647.  
  6648. **Q*: I have a program that reads struct contents from a binary file.  It
  6649. works OK when compiled with BC, but reads garbage when compiled with DJGPP.
  6650. This must be a bug in DJGPP, right?*
  6651.  
  6652. *A* : No, it's not a bug.  GCC generates 32-bit code, and in that mode, there
  6653. is a significant penalty (in terms of run-time performance) for unaligned
  6654. accesses, like accessing a 16-bit short which isn't aligned on a word
  6655. boundary, or accessing a 32-bit int which isn't aligned on a dword boundary.
  6656. To produce faster code, GCC pads struct fields so that each field can be
  6657. accessed without delays; this sometimes produces struct size which is larger
  6658. than the sum of the sizes of its fields.  If you need to minimize this
  6659. padding (e.g., if your program uses large arrays of such structs, where
  6660. padding will waste a lot of memory), lay out your structures so that the
  6661. longer fields are before the shorter ones.  For example, let's say that you
  6662. have a struct defined thus:
  6663.  
  6664.        struct my_struct {
  6665.          char name[7];
  6666.          unsigned long offset;
  6667.          double quality;
  6668.        };
  6669.  
  6670. To make such a struct use the least number of bytes, rearrange the fields,
  6671. like this:(Note that this still allows the struct to be padded at the end,
  6672. though.)
  6673.  
  6674.        struct my_struct {
  6675.          double quality;
  6676.          unsigned long offset;
  6677.          char name[7];
  6678.        };
  6679.  
  6680. If the layout of the structure cannot be changed (e.g., when it must match
  6681. some external specification, like a block of data returned by a system call),
  6682. you can use the `__attribute__((packed))' extension of GCC (See the Gcc docs
  6683. in "GNU C/C++ Manual", or point your Web browser to
  6684. http://www.delorie.com/gnu/docs/gcc/gcc_83.html#SEC86.) to prevent GCC from
  6685. padding the structure fields; this will make accesses to some of the fields
  6686. slower.
  6687.  
  6688. Beginning with version 2.7.0, GCC has a command-line option `-fpack-struct'
  6689. which causes GCC to pack all members of all structs together without any
  6690. holes, just as if you used `__attribute__((packed))' on every struct
  6691. declaration in the source file you compile with that switch.  If you use this
  6692. switch, be sure that source files which you compile with it don't use *any*
  6693. of the structures defined by library functions, or you will get some fields
  6694. garbled (because the library functions weren't compiled with that switch).
  6695. Alternatively, you could declare any single structure to be packed, like so:
  6696.  
  6697.        struct {
  6698.          char name[7];
  6699.          unsigned long offset;
  6700.          double quality;
  6701.        } __attribute__ ((packed));
  6702.  
  6703. However, note that the latter will only work when you compile it as a C
  6704. source; C++ doesn't allow such syntax, and you will have to fall back to
  6705. declaring each struct field with the packed attribute.  Therefore, it's best
  6706. to only use declarations such as above if you are *certain* it won't be ever
  6707. compiled as a C++ source.
  6708.  
  6709. The padding of struct fields should be considered when you read or write
  6710. struct content from or to a disk file.  In general, this should only be done
  6711. if the file is read and written by the same program, because the exact layout
  6712. of the struct fields depends on some subtle aspects of code generation and
  6713. the compiler switches used, and these may differ between programs, even if
  6714. they were compiled by the same compiler on the same system.  If you do need
  6715. this method, be aware of the struct field padding and don't assume that the
  6716. number of the file bytes that the structure uses is equal to the sum of the
  6717. fields' sizes, even if you instructed the compiler to pack structs: GCC still
  6718. can add some padding after the last field.  So always use `sizeof struct foo'
  6719. to read and write a structure.
  6720.  
  6721. Another problem with porting programs that read structs from binary files is
  6722. that the size of some data types might be different under different
  6723. compilers.  Specifically, an `int' is 16-bit wide in most DOS-based
  6724. compilers, but in DJGPP it's 32-bit wide.
  6725.  
  6726. The best, most robust and portable way to read and write structs is through a
  6727. `char' buffer, which your code then uses to move the contents into or out of
  6728. the struct fields, one by one.  This way, you always know what you are doing
  6729. and your program will not break down if the padding rules change one day, or
  6730. if you port it to another OS/compiler.  The ANSI-standard `offsetof' macro
  6731. comes in handy in many such cases.
  6732.  
  6733. 22.10 C++ doesn't pack structs!
  6734. ===============================
  6735.  
  6736. **Q*: When I use `struct ffblk' from the header `dir.h' in a C++ program, I
  6737. get garbage in some fields of the structure!*
  6738.  
  6739. *A* :  There is a known bug in GCC 2.7.2: the C++ compiler effectively
  6740. ignores the `__attribute__((packed))' directives, so the structures end up
  6741. being not packed.  DJGPP v2.01 comes with GCC 2.7.2.1 which corrected that
  6742. bug, so upgrade.  As a work-around, surround the declaration of the structure
  6743. that needs to be packed with `#pragma pack', like this:
  6744.  
  6745.        #ifdef __cplusplus
  6746.        #pragma pack(1)
  6747.        #endif
  6748.        .
  6749.        .
  6750.        .
  6751.        #ifdef __cplusplus
  6752.        #pragma pack()
  6753.        #endif
  6754.  
  6755. 22.11 How to avoid "Abort, Retry, Fail" messages
  6756. ================================================
  6757.  
  6758. **Q*: How do I write a program that accesses floppy and CD-ROM drives, but
  6759. avoids popping that "Abort, Retry, Fail?" message from DOS?*
  6760.  
  6761. **Q*: Other DOS compilers supply a function named `harderr' or `_harderr' to
  6762. hook the critical-error interrupt 24h, but DJGPP doesn't seem to have
  6763. these...*
  6764.  
  6765. *A* :  Under DPMI, Int 24h is always hooked by the DPMI server, since Int 24h
  6766. is issued by the real-mode DOS code, and it is not possible to terminate a
  6767. DPMI client (like DJGPP program) from real mode, if you press `A' in response
  6768. to that prompt.  The default handler under most DPMI servers will just set
  6769. `AL' register to 3 and do an `IRET', thus silently failing the DOS call that
  6770. triggered Int 24h.  The DJGPP startup code also hooks the protected-mode Int
  6771. 24h with a handler that fails the DOS call as described above.  So in most
  6772. circumstances you won't see that DOS prompt at all; your program will just
  6773. see a failed DOS call.
  6774.  
  6775. However, some DPMI hosts (notably, QDPMI), will sometimes crash your program
  6776. if it generates Int 24h, for instance when you access an empty floppy drive.
  6777. In such cases, or when the default action of failing the DOS call is not good
  6778. enough, you will have to hook Int 24h with your handler.  This should be done
  6779. in exactly the same manner as hooking hardware interrupts (see how to set an
  6780. interrupt handler in Section 18.9), because Int 24h is one of the few
  6781. software interrupts that, like all hardware interrupts, are always reflected
  6782. to the protected-mode handler first.  Note that `CWSDPMI' currently doesn't
  6783. support hooking Int 24h; if you set an interrupt handler, it won't be called.
  6784.  
  6785. There are ways to avoid program crashes due to Int 24h (under those DPMI
  6786. hosts that exhibit this buggy behavior) other than to install a handler for
  6787. it.  For instance, you can test if the floppy drive is empty with a BIOS call
  6788. before accessing it with DOS functions; there are also similar ways to check
  6789. if a CD-ROM drive is empty.  The library function `getmntent' (See getmntent
  6790. in "libc.a reference", or point your Web browser to
  6791. http://www.delorie.com/djgpp/doc/libc-2.01/libc_337.html#SEC337.) can be used
  6792. to detect all the drives that can be safely accessed by DOS; or you can
  6793. borrow some of the internal functions used by `getmntent' from the library
  6794. source distribution, e.g.
  6795. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2/djlsr201.zip.
  6796.  
  6797. 22.12 What is that `go32-v2.exe' program?
  6798. =========================================
  6799.  
  6800. **Q*: What is go32-v2 for?*
  6801.  
  6802. *A* :  The `go32-v2' program does the following:
  6803.  
  6804.    * With no command-line arguments, it prints the available physical and
  6805.      virtual memory, much like `go32' did in v1.x.
  6806.  
  6807.    * It can run unstubified v2 COFF images, like this:
  6808.  
  6809.            go32-v2 myprog
  6810.  
  6811.    * If you rename it to `go32.exe' and put on your `PATH' before the v1.x
  6812.      `go32.exe', it can also run a v1 COFF images, by loading the v1.x `go32'
  6813.      and letting it do the job.  With this setup, you can run v2 programs
  6814.      from v1.x programs, because the v1.x program will load `go32-v2' (since
  6815.      it found it first on the PATH) which knows how to run v2 images, instead
  6816.      the original `go32' which cannot.
  6817.  
  6818. 22.13 What is DXE?
  6819. ==================
  6820.  
  6821. **Q*: What is DXE?*
  6822.  
  6823. **Q*: Can I make a DLL using the DXE support?*
  6824.  
  6825. **Q*: Where can I find information or examples about writing/loading the DXE
  6826. files?*
  6827.  
  6828. *A* :  DXE is a limited facility to dynamically load code which is rarely
  6829. needed in DJGPP.  An example is the floating-point emulator code (see the
  6830. details of DJGPP FP emulator in Section 11.1) which is only used on those few
  6831. machines that lack an FPU.  The DXE design is intentionally limited to keep
  6832. it as simple as possible, so that the code that loads a DXE could be small
  6833. (it's a few hundreds bytes).  Because of this, there are a number of
  6834. limitations in the DXE mechanism that prevent using it for full-fledged
  6835. dynamic linking (i.e., a DLL).  For instance, the DXE module cannot access
  6836. variables or functions in the main module.  Unloading a DXE is also not
  6837. supported (but I'm told you can add this by making afew simple changes in the
  6838. C library).
  6839.  
  6840. The only place you can find some docs and examples of writing and using a DXE
  6841. is in the file `djtst201.zip' in the DJGPP "tests" distribution, e.g.
  6842. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2/djtst201.zip.  The example
  6843. there is *exceedingly* simplistic, but then so is the entire DXE mechanism...
  6844.  
  6845. 22.14 Long Filenames Don't Work!
  6846. ================================
  6847.  
  6848. **Q*: I cannot make Info find some of its files under Win95...*
  6849.  
  6850. **Q*: Why does Make behave as if some of the files were not there?*
  6851.  
  6852. *A* : Are you running DJGPP v2.0 on Win95 with long filename support enabled
  6853. (LFN=y in the environment)?  If so, set LFN=n from the DOS prompt and try
  6854. again.  If the problems go away, they are probably due to known bugs in some
  6855. v2.0 programs wrt the LFN support.  Make and Info which came with DJGPP v2.0
  6856. are two programs which are known to reveal these bugs.  Before you decide
  6857. that you are a victim of these bugs, though, make sure that all the files
  6858. that your programs need to access have been renamed to their long names.  For
  6859. example, if Make needs to find a file called `ALongFileName.cc' (because the
  6860. Makefile tells it to build `ALongFileName.o'), make sure there indeed is such
  6861. a file in the directory.  Sometimes people use archive tools (like `PKZIP')
  6862. that truncate long names, even on Win95, when they open an archive, which
  6863. leaves you with names like `alongfil.cc', which is not the same as the
  6864. original name when LFN is supported.  Be sure to use archivers that support
  6865. long filenames, e.g. use `DJTAR' when you open `.tar.gz' archives, or rename
  6866. all the files to their original long names after you open the archive.
  6867.  
  6868. If the problems persist even though the filenames are correct, upgrade to
  6869. DJGPP v2.01 or later, where all programs should support long filenames
  6870. properly.  If you cannot upgrade, you will have to disable LFN support (set
  6871. LFN=n from the DOS prompt, setting it in `DJGPP.ENV' does not always work in
  6872. DJGPP v2.0).
  6873.  
  6874. 22.15 Make says "missing separator"
  6875. ===================================
  6876.  
  6877. **Q*: When I invoke Make, it refuses to do anything and prints this cryptic
  6878. message:*
  6879.  
  6880.        makefile:10: *** missing separator.  Stop.
  6881.  
  6882. *Now what kind of excuse is that?*
  6883.  
  6884. *A* : Unlike most other DOS Make programs which accept any whitespace
  6885. character at the beginning of a command in a rule, GNU Make insists that
  6886. every such line begins with a TAB.  (Most other Unix Make programs also
  6887. require TABs.)  Make sure that the line whose number is printed in the error
  6888. message (in this case, line 10) begins with a TAB.
  6889.  
  6890. There are editors that replace TABs with spaces, so even a Makefile that used
  6891. to work can become unworkable if you edit them with such an editor.
  6892.  
  6893. Another, more rare, cause of the above error message is if you use static
  6894. pattern rules (with the `%' character) incorrectly.  Read the documentation
  6895. that comes with Make carefully and try to find the error.
  6896.  
  6897. 22.16 What is in that `zoneinfo' directory?
  6898. ===========================================
  6899.  
  6900. **Q*: When I installed DJGPP v2, it created a directory named `zoneinfo' with
  6901. a lot of small files that take up 3.5MB of my disk space.  What are they for?
  6902. Can I delete them?*
  6903.  
  6904. *A* :  These files exist so that time-related library functions can correctly
  6905. calculate the offset between the local time and the "UTC" (Universal
  6906. Coordinated Time).  This offset is required when you get files from another
  6907. time-zone, like from the Internet, or when you download an archive that was
  6908. compressed in another time-zone.  If you don't care about file time stamps
  6909. being incorrect in such cases, you can delete all those files and never look
  6910. back.
  6911.  
  6912. You might wonder why we need all these zoneinfo files when the UTC offset
  6913. *is* required.  Well, the simplest way to tell programs what the UTC offset
  6914. is, is to have the user specify a single number which is the offset; but then
  6915. this number needs to be changed twice a year, to accommodate for the daylight
  6916. saving time.  Another, not-quite-so-simple way is to have the user specify
  6917. the current UTC offset and the DST rules; but this is a tedious and
  6918. error-prone process, and many users get it wrong.  Both of these methods have
  6919. the drawback that if the rules change, programs misinterpret old time-stamps,
  6920. since they treat them according to new rules.  Using a table that is read from
  6921. a file and includes the offset calculation rules for every year avoids all
  6922. these problems and requires the user to point the `TZ' environment variable
  6923. to the file that is pertinent to his/her time zone, which is easy:
  6924.  
  6925.       set TZ=c:/djgpp/zoneinfo/israel
  6926.  
  6927. *or*
  6928.  
  6929.       set TZ=c:/djgpp/zoneinfo/us/alaska
  6930.  
  6931. To find the rule suitable for your location, look into the `src' subdirectory
  6932. of `zoneinfo' and browse the file whose name is your continent/part of the
  6933. world.  If no binary file exists with the name of your zone, you can create
  6934. one with using the time-zone compiler `zic', whose source is also in the
  6935. `src' subdirectory.
  6936.  
  6937. A public domain time-zone database exists, and is updated from time to time
  6938. with the latest world-wide changes to the offset calculation rules.  (The
  6939. rules change because politicians in different countries make laws that change
  6940. the local clock settings.)  The contents of the `zoneinfo' directory which
  6941. comes with DJGPP is based on this database, but if you want the latest rules,
  6942. you can download them from the net, e.g. ftp://elsie.nci.nih.gov/pub/ as
  6943. `tzdata*.tar.gz'; `tzcode*.tar.gz' in the same directory includes the
  6944. programs that can be used to generate the offset tables from their source in
  6945. `tzdata*.tar.gz', the latest implementations of POSIX library functions that
  6946. use time-zone information, and the man pages that document the rules and the
  6947. software.  The last update as of this writing was in May 1996.
  6948.  
  6949. On any single machine, you don't need more than a single file from that
  6950. directory, which is the file for your time zone; once you find that file, you
  6951. can safely delete the rest.  But if you distribute a program that uses the TZ
  6952. setting, you will have to include all of the files, or tell your users how to
  6953. get and install them.
  6954.  
  6955. 22.17 Generating the FAQ in your favorite format
  6956. ================================================
  6957.  
  6958. **Q*: How can I generate the FAQ list in a format I'm used to?*
  6959.  
  6960. *A* :  First, you need to get the FAQ sources.  The sources of the latest
  6961. version of this FAQ list can always be found as `faqNNNs.zip' on DJ Delorie's
  6962. server, e.g. ftp://ftp.delorie.com/pub/djgpp/v2faq/faq210s.zip and on
  6963. SimTel.NET mirrors, e.g.
  6964. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2/faq210s.zip.  This includes
  6965. the source file (written in Texinfo), and all the auxiliary tools required to
  6966. produce the Info, plain-ASCII, HTML, and a few other versions of the FAQ
  6967. list; the FAQ in all these formats is available in a separate ZIP archive as
  6968. `faqNNNb.zip' from DJ Delorie's server, e.g.
  6969. ftp://ftp.delorie.com/pub/djgpp/v2faq/faq210b.zip or from SimTel.NET mirrors,
  6970. e.g. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2/faq210b.zip.  Currently,
  6971. this includes the Info version, the text (ASCII) version and an HTML version
  6972. as a single large `.html' file.  More formats will be available as the tools
  6973. for their generation are developed/tested.
  6974.  
  6975. If none of these formats is good enough for you, here are some tools
  6976. available to generate the FAQ list in other formats.  If you know about any
  6977. format not mentioned below that can be generated using widely available
  6978. tools, please drop me a note so I could update this list and consider that
  6979. format or those tools for inclusion in a future release of the FAQ.  If you
  6980. develop any such tools, consider uploading them to a site where they will be
  6981. publicly available, and tell me about that site.
  6982.  
  6983. Note that the FAQ source is a heavy user of the Texinfo macro facility, so
  6984. any conversion program that doesn't support Texinfo macros will probably have
  6985. hard time coping with the FAQ.  When confronted with this problem try feeding
  6986. the converter with the macro-expanded version of the FAQ (the Makefile in the
  6987. source distribution has a special target for such cases).
  6988.  
  6989. A program called `Makertf' can reportedly be used to convert a Texinfo
  6990. sources of this FAQ to the "Rich File Format" which can then either be
  6991. browsed by an RTF browser (such as Adobe Acrobat) or converted into a Windows
  6992. Help file with a Windows Help compiler.  `Makertf' is available from CCT
  6993. mirrors, e.g. ftp://ftp.coast.net/Coast/win3/winhelp/mkrtf104.zip.  The
  6994. Windows Help Compiler is available via anonymous ftp from the Microsoft ftp
  6995. site, e.g. ftp://ftp.microsoft.com/Softlib/MSFILES/HC305.EXE.
  6996.  
  6997. There also a program called `INFNG' that can be used to convert the Info
  6998. (*not* Texinfo) version of the FAQ to the Norton Guide format.  `INFNG' can
  6999. be downloaded from the DJGPP archive, e.g.
  7000. ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2misc/infng100.zip.
  7001.  
  7002. 23. About this FAQ
  7003. ******************
  7004.  
  7005.   Maintainer: Eli Zaretskii <eliz@is.elta.co.il>.
  7006.  
  7007.   This FAQ is Copyright (C) 1994, 1995, 1996, 1997 by Eli Zaretskii
  7008. <eliz@is.elta.co.il>.  It may be freely redistributed with the DJGPP package
  7009. or any part thereof, provided that you don't prevent anybody else from
  7010. redistributing it on the same terms, and that this copyright notice is left
  7011. intact.
  7012.  
  7013.   Comments about, suggestions for, or corrections to this FAQ list are welcome.
  7014. Please make sure to include in your mail the version number of the document
  7015. to which your comments apply (you can find the version at the beginning of
  7016. this FAQ list).
  7017.  
  7018.   Much of the info in this FAQ list was taken from the DJGPP mailing list/news
  7019. group traffic, so many of you have (unbeknownst to you) contributed to this
  7020. list.  The following people read this list in its previous versions and
  7021. provided useful feedback, comments, information and/or suggestions:
  7022.  
  7023.      John M. Aldrich <fighteer@cs.com>
  7024.      Anthony Appleyard <A.APPLEYARD@fs2.mt.umist.ac.uk>
  7025.      John Bodfish <bodfish@austen.notis.com>
  7026.      Francois Charton <deef@pobox.oleane.com>
  7027.      Bill Currie <bill_currie@blackmagic.tait.co.nz>
  7028.      Bill Davidson <bdavidson@ra.isisnet.com>
  7029.      DJ Delorie <dj@delorie.com>
  7030.      Tom Demmer <Demmer@LStM.Ruhr-Uni-Bochum.De>
  7031.      Juergen Erhard <jae@laden.ilk.de>
  7032.      Jeremy Filliben <prime@UDel.Edu>
  7033.      James W. Haefner <Jim@anolis.bnr.usu.edu>
  7034.      Koen Van Herck <kvhk@barco.com>
  7035.      Robert Hoehne <Robert.Hoehne@Mathematik.TU-Chemnitz.DE>
  7036.      Gordon Hogenson <ghogenso@u.washington.edu>
  7037.      Harry Johnston <omega@es.co.nz>
  7038.      Martynas Kunigelis <martynas.kunigelis@vm.ktu.lt>
  7039.      Pieter Kunst <kunst@prl.philips.nl>
  7040.      Y. Lazarovitch <yitzg@haven.ios.com>
  7041.      Alexander Lehmann <lehmann@mathematik.th-darmstadt.de>
  7042.      Marty Leisner <leisner@sdsp.mc.xerox.com>
  7043.      Dave Love <d.love@dl.ac.uk>
  7044.      Rob Nader <naderr@topaz.cqu.edu.au>
  7045.      Eric Nicolas <nicolas@JUPITER.saclay.cea.fr>
  7046.      Elliott Oti <e.oti@stud.warande.ruu.nl>
  7047.      Esa A E Peuha <peuha@cc.helsinki.fi>
  7048.      Walter Prins <prins@quark.cs.sun.ac.za>
  7049.      Steve Salter <salters@admin.fanshawec.on.ca>
  7050.      Charles Sandmann <sandmann@clio.rice.edu>
  7051.      Terrel Shumway <Shumw001@Cerritos.edu>
  7052.      Andrew Szymkowiak <aes@solia.gsfc.nasa.gov>
  7053.      Launey Thomas <ljt@sierrasemi.com>
  7054.      Chris Tilbury <C.J.Tilbury@estate.warwick.ac.uk>
  7055.      Stephen Turnbull <turnbull@shako.sk.tsukuba.ac.jp>
  7056.      Santiago Vila <sanvila@pizarro.unex.es>
  7057.      Ronan Waide <waider@waider.ie>
  7058.      Morten Welinder <terra@diku.dk>
  7059.      Anthony Edward Wesley <awesley@galaxy.anutech.com.au>
  7060.      Mark H. Wood <mwood@mhw.OIT.IUPUI.EDU>
  7061.  
  7062. 24. Topic Index
  7063. ***************
  7064.  
  7065.   This is an alphabetical list of all the topics covered in this FAQ.  Use it
  7066. to search for a description of your problem and follow the link to find the
  7067. answer(s).
  7068.  
  7069.  
  7070.  
  7071. * !proxy method of passing long command lines: Section 16.4.
  7072. * "Far" declarations, porting to DJGPP: Section 17.7.
  7073. * "Huge" declarations, porting to DJGPP: Section 17.7.
  7074. * "Near" declarations, porting to DJGPP: Section 17.7.
  7075. * -ansi switch and C++-style comments in C programs: Section 8.3.
  7076. * -fconserve-space switch: Section 8.14.
  7077. * -fstrength-reduce optimization, disabled by default: Section 14.2.
  7078. * -msoft-float switch to GCC: Section 11.4.
  7079. * -traditional switch and C++-style comments in C programs: Section 8.3.
  7080. * .lib libraries, using with GCC: Section 17.5.
  7081. * .o files from EMXAOUT can't be put into a library: Section 17.5.
  7082. * .obj object files, using with GCC: Section 17.5.
  7083. * 16-bit code, using with DJGPP: Section 17.6.
  7084. * 68K targets, cross-compiling with DJGPP: Section 22.7.
  7085. * @ character, how to pass it to programs: Section 16.3.
  7086. * ^Z character at end of DJGPP.ENV: Section 6.2.
  7087. * __crt0_glob_function, disable filename globbing: Section 16.2.
  7088. * __DJGPP__ pre-processor symbol: Section 8.6.
  7089. * __dpmi_get_memory_information, doesn't change after free/malloc: Section 15.2.
  7090. * __dpmi_get_protected_mode_interrupt_vector: Section 18.9.
  7091. * __dpmi_get_real_mode_interrupt_vector: Section 18.9.
  7092. * __dpmi_int, calling DOS/BIOS services: Section 18.1.
  7093. * __dpmi_int, high in program's profile: Section 13.5.
  7094. * __dpmi_int, how to pass buffers: Section 18.2.
  7095. * __dpmi_int, use to invoke software interrupts: Section 18.3.
  7096. * __dpmi_simulate_real_mode_interrupt, need zero SS, SP and FLAGS: Section 18.3.
  7097. * __dpmi_YYY vs _go32_XXX, which one to use: Section 18.10.
  7098. * __GO32__ pre-processor symbol: Section 8.6.
  7099. * __pure_virtual, unresolved function: Section 8.12.
  7100. * __tb, an alias for the address of transfer buffer: Section 18.2.
  7101. * _AX variable, porting to DJGPP: Section 17.8.
  7102. * _BP variable, porting to DJGPP: Section 17.8.
  7103. * _BX variable, porting to DJGPP: Section 17.8.
  7104. * _CX variable, porting to DJGPP: Section 17.8.
  7105. * _DI variable, porting to DJGPP: Section 17.8.
  7106. * _dos_ds, a selector to access conventional memory: Section 18.4.
  7107. * _DS variable, porting to DJGPP: Section 17.8.
  7108. * _DX variable, porting to DJGPP: Section 17.8.
  7109. * _ES variable, porting to DJGPP: Section 17.8.
  7110. * _go32_dpmi_allocate_iret_wrapper: Section 18.9.
  7111. * _go32_dpmi_chain_protected_mode_interrupt_vector: Section 18.9.
  7112. * _go32_remaining_physical_memory, doesn't change after free/malloc: Section 15.2.
  7113. * _go32_XXX vs __dpmi_YYY, which one to use: Section 18.10.
  7114. * _SI variable, porting to DJGPP: Section 17.8.
  7115. * _stklen, setting stack size: Section 15.9.
  7116. * Accessing absolute addresses above 1MB: Section 18.7.
  7117. * Accessing absolute addresses in conventional memory: Section 18.4.
  7118. * Accessing absolute addresses with dedicated selector: Section 18.4.
  7119. * Accessing C variables from inline assembly: Section 18.13.
  7120. * Accessing VBE 2.0 linear frame buffer: Section 10.2.
  7121. * Accessing video memory: Section 10.2.
  7122. * Alignment of data by GAS can slow-down code: Section 14.3.
  7123. * Allegro library, failure to compile: Section 8.19.
  7124. * Announcements, mailing list: Section 20.3.
  7125. * Archives, DJGPP mailing list/News group, how to search: Section 6.11.
  7126. * argv[0] when program runs under a debugger: Section 12.1.
  7127. * Asking for help: Section 6.12.
  7128. * Assembly source, code produced by Gas: Section 17.2.
  7129. * Assembly source, converting to AT&T syntax: Section 17.3.
  7130. * Assembly source, converting to protected mode: Section 17.4.
  7131. * Assembly source, GCC/Gas syntax: Section 17.1.
  7132. * Assembly syntax: Section 17.1.
  7133. * AT&T vs Intel assembly syntax: Section 17.1.
  7134. * atan, inaccuracies with FP emulator: Section 11.6.
  7135. * Automated downloading from a PC: Section 4.7.
  7136. * Automated downloading from a Unix box: Section 4.7.
  7137. * Automated FTP from a Unix box: Section 4.7.
  7138. * Automatic variables, how much memory: Section 15.9.
  7139. * Bad format, profiler error message: Section 13.3.
  7140. * Binary data I/O: Section 9.3.
  7141. * BIOS service calls: Section 18.1.
  7142. * BIOS service calls which need buffers: Section 18.2.
  7143. * BIOS setup, influence on compilation speed: Section 7.1.
  7144. * Breakpoints don't work in GDB under Windows: Section 12.9.
  7145. * Browsing documentation: Section 5.1.
  7146. * Buffered I/O, effect of buffer size on I/O speed: Section 14.4.
  7147. * Bug report, how to submit: Section 22.1.
  7148. * Bug-tracking system for DJGPP: Section 22.1.
  7149. * Bugs, how to browse a list of known DJGPP problems: Section 22.1.
  7150. * C library, legal restrictions: Section 19.2.
  7151. * C programs compilation, recommended system RAM: Section 3.1.
  7152. * C++ class variables under GDB: Section 12.7.
  7153. * C++ debugging with stabs information: Section 12.7.
  7154. * C++ method names under GDB: Section 12.7.
  7155. * C++ programs compilation, recommended system RAM: Section 3.1.
  7156. * C++ programs, large executable: Section 8.14.
  7157. * C++ programs, problems with packed structs: Section 22.10.
  7158. * C++ source, debugger cannot find: Section 12.6.
  7159. * C++ STL library, not in lgp271b distribution: Section 8.7.
  7160. * C++, missing header files: Section 8.2.
  7161. * C++-style comments in C programs, GCC won't compile: Section 8.3.
  7162. * Caldera OpenDOS, DPMI services crash DJGPP: Section 6.2.
  7163. * Calling 16-bit code from DJGPP: Section 17.6.
  7164. * calloc fails under EMM386 or HIMEM: Section 15.7.
  7165. * calloc fails under QDPMI or Windows: Section 15.4.
  7166. * calloc fails under Windows 3.x: Section 15.5.
  7167. * calloc fails under Windows 95: Section 15.6.
  7168. * calloc, effect on "Fat DS": Section 18.6.
  7169. * Can't find node "Top", Info message:   Info can't find ``Top''.
  7170. * CCT mirrors' list: Section 4.2.
  7171. * CD-ROM, getting DJGPP: Section 4.4.
  7172. * Chaining interrupt: Section 18.9.
  7173. * Changing GNU/DJGPP programs: Section 22.1.
  7174. * Child processes, spawning under OS/2: Section 3.2.
  7175. * Child programs, how much memory is left: Section 15.8.
  7176. * Class method name in GDB: Section 12.7.
  7177. * Class static variable name in GDB: Section 12.7.
  7178. * Code is slow due to incorrect alignment by GAS: Section 14.3.
  7179. * Code page change might prevent MSHELL from working: Section 12.5.
  7180. * Code quality, GCC: Section 14.1.
  7181. * Code speed, slower in v2.x: Section 14.2.
  7182. * Code, DJGPP-specific: Section 8.6.
  7183. * COFF output from linker, how to get: Section 12.3.
  7184. * COFF output, required for profiling: Section 13.3.
  7185. * Color text cannot be printed with `printf': Section 9.4.
  7186. * Command line, disabling filename expansion/globbing: Section 16.2.
  7187. * Command line, escaping special characters: Section 16.3.
  7188. * Command line, filename expansion/globbing: Section 16.1.
  7189. * Command lines, longer than 126 characters: Section 16.4.
  7190. * Command-line arguments: Chapter 16.
  7191. * Comments, C++-style in C programs: Section 8.3.
  7192. * Commercial programs, writing with DJGPP: Section 19.1.
  7193. * Compatibility, hardware, general: Chapter 3.
  7194. * Compatibility, Linux: Section 3.1.
  7195. * Compatibility, Novell NWDOS 7: Section 3.1.
  7196. * Compatibility, operating systems, general: Chapter 3.
  7197. * Compatibility, OS/2: Section 3.1.
  7198. * Compatibility, Warp: Section 3.1.
  7199. * Compatibility, Windows 3.x: Section 3.1.
  7200. * Compatibility, Windows 9x: Section 3.1.
  7201. * Compatibility, Windows/NT: Section 3.1.
  7202. * Compilation for debugging: Section 12.1.
  7203. * Compilation messages, bogus: Section 8.4.
  7204. * Compilation progress, GCC switch: Section 6.3.
  7205. * Compilation speed: Section 7.1.
  7206. * Compile-time problems: Chapter 8.
  7207. * Compiler crashes, which subprogram of: Section 6.9.
  7208. * Compiler speed: Chapter 7.
  7209. * Compiling GCC and CPP: Section 3.8.
  7210. * Compiling GCC and CPP, RAM disk: Section 3.9.
  7211. * Compiling large programs, disk cache settings: Section 3.8.
  7212. * Compiling large programs, RAM disk settings: Section 3.8.
  7213. * Compiling large source files: Section 3.8.
  7214. * Compiling Objective C sources: Section 8.5.
  7215. * Complex class is not in libgpp.a: Section 8.11.
  7216. * Complex class, porting to libgpp.a 2.7.1 and later: Section 8.11.
  7217. * Complex template class: Section 8.11.
  7218. * Compressing DJGPP executables: Section 8.15.
  7219. * Configuration, for optimal performance: Section 3.9.
  7220. * Configuration, reasonable: Section 3.8.
  7221. * Configuration, the best: Section 3.7.
  7222. * Conventional memory, moving data to/from: Section 18.4.
  7223. * Conversion of the FAQ to different formats: Section 22.17.
  7224. * Converting DOS .obj/.lib files to GCC: Section 17.5.
  7225. * Converting DOS code to DJGPP: Chapter 17.
  7226. * Coprocessor setup, change with _control87: Section 11.5.
  7227. * Copyleft, effect on DJGPP: Section 19.1.
  7228. * Copyright issues: Chapter 19.
  7229. * Crash traceback, how to read: Section 9.2.
  7230. * Crash, DJGPP programs: Chapter 6.
  7231. * Crash, numeric exception: Section 11.5.
  7232. * Crashes, general troubleshooting: Section 6.9.
  7233. * Crashes, v2.0 programs: Section 9.1.
  7234. * Critical error handling in DJGPP: Section 22.11.
  7235. * Cross-compiling with DJGPP: Section 22.7.
  7236. * crt0.o, GCC can't find: Section 8.1.
  7237. * Ctrl-C in debugged programs: Section 12.9.
  7238. * Curses library for DJGPP: Section 22.2.
  7239. * Cygnus GCC port to Windows: Section 3.3.
  7240. * Cygnus port of GCC for WinNT and Win95: Section 3.6.
  7241. * DEADBEAF, use to spot uninitialized memory: Section 9.1.
  7242. * Debugger cannot find C++ source: Section 12.6.
  7243. * Debugger causes programs to overflow the stack: Section 15.9.
  7244. * Debugger crashes on programs compiled for profiling: Section 12.9.
  7245. * Debugger crashes on programs which use exceptions: Section 12.9.
  7246. * Debugger crashes under QEMM/QDPMI: Section 12.2.
  7247. * Debugger doesn't know about #include'd source: Section 12.8.
  7248. * Debugger doesn't pass signals to debuggee: Section 12.9.
  7249. * Debugger GP Faults on Windows 3.x: Section 12.9.
  7250. * Debugger, usage: Section 12.1.
  7251. * Debuggers for DJGPP programs: Section 12.1.
  7252. * Debuggers use transfer buffer: Section 12.4.
  7253. * Debugging C++ programs: Section 12.6.
  7254. * Debugging C/C++ code generated by a program: Section 12.8.
  7255. * Debugging graphics programs: Section 12.5.
  7256. * Debugging issues: Chapter 12.
  7257. * Debugging symbols, how to strip from executables: Section 8.15.
  7258. * Debugging with GDB, needs COFF output: Section 12.3.
  7259. * Description of GNU style of mangling C++ names: Section 12.7.
  7260. * Development environments for DJGPP: Section 22.2.
  7261. * Differences between SimTel and CCT ftp sites: Section 4.1.
  7262. * Direct hardware access on Win/NT: Section 3.3.
  7263. * Disabling globbing in filenames: Section 16.2.
  7264. * Disabling QDPMI: Section 12.2.
  7265. * Disabling virtual memory for CWSDPMI: Section 7.1.
  7266. * Disabling wildcard expansion: Section 16.2.
  7267. * Disk cache, influence on compilation speed: Section 7.1.
  7268. * Disk cache, recommended settings: Section 3.9.
  7269. * Disk cache, when compiling large programs: Section 3.8.
  7270. * Disk space, required for installation: Section 3.1.
  7271. * Disk space, using less of it: Section 4.7.
  7272. * Distributing DJGPP programs: Section 9.5.
  7273. * Distributing DJGPP programs, FP emulator: Section 11.1.
  7274. * DJGPP applications, legal restrictions: Section 19.1.
  7275. * DJGPP archives, how to search: Section 6.11.
  7276. * DJGPP as cross-compiler: Section 22.7.
  7277. * DJGPP distribution, list of: Section 4.5.
  7278. * DJGPP Documentation: Chapter 5.
  7279. * DJGPP documentation, in man page format: Section 5.6.
  7280. * DJGPP documentation, in PostScript format: Section 5.4.
  7281. * DJGPP documentation, look in source distributions: Section 5.5.
  7282. * DJGPP documentation, printing: Section 5.3.
  7283. * DJGPP documentation, reading as ASCII file: Section 5.2.
  7284. * DJGPP documentation, reading with a Web browser: Section 5.4.
  7285. * DJGPP documentation, see source files: Section 5.7.
  7286. * DJGPP documentation, where to find it: Section 5.1.
  7287. * DJGPP environment variable, how to set and test: Section 8.1.
  7288. * DJGPP environment variable, setting under LFN: Section 8.1.
  7289. * DJGPP mailing list, duplicate messages: Section 20.6.
  7290. * DJGPP mailing list, how to post: Section 20.2.
  7291. * DJGPP mailing list, how to subscribe: Section 20.3.
  7292. * DJGPP mailing list, how to unsubscribe: Section 20.4.
  7293. * DJGPP mailing list, in digest form: Section 20.3.
  7294. * DJGPP mailing list, no messages: Section 20.5.
  7295. * DJGPP mailing list/news group, read via WWW: Section 20.4.
  7296. * DJGPP News group: Section 20.7.
  7297. * DJGPP News group, reading via WWW: Section 20.3.
  7298. * DJGPP programs, problems with: Chapter 6.
  7299. * DJGPP programs, problems with DPMI host: Section 6.2.
  7300. * DJGPP programs, profiling: Section 13.1.
  7301. * DJGPP software, where to upload: Section 22.6.
  7302. * DJGPP users, asking for help: Section 6.12.
  7303. * DJGPP utilities, legal restrictions: Section 19.2.
  7304. * DJGPP v2.x, alternative DPMI hosts: Section 21.2.
  7305. * DJGPP won't run, prints "No DPMI": Section 6.1.
  7306. * DJGPP, a list of packages: Section 4.5.
  7307. * DJGPP, downloading via e-mail: Section 4.4.
  7308. * DJGPP, downloading with FTP: Section 4.3.
  7309. * DJGPP, downloading with Gopher: Section 4.4.
  7310. * DJGPP, downloading with WWW: Section 4.4.
  7311. * DJGPP, how to get it: Chapter 4.
  7312. * DJGPP, sample code: Section 22.2.
  7313. * DJGPP, what it is: Chapter 2.
  7314. * DJGPP, where to download: Section 4.1.
  7315. * DJGPP-ANNOUNCE mailing list: Section 20.3.
  7316. * DJGPP-compiled programs can't find DPMI: Section 9.5.
  7317. * DJGPP-specific code: Section 8.6.
  7318. * DJGPP.ENV syntax explained: Section 8.1.
  7319. * DJGPP.ENV, trailing junk crashes Info: Section 6.2.
  7320. * djgpp_first_ctor, unresolved by linker: Section 8.13.
  7321. * djgpp_first_dtor, unresolved by linker: Section 8.13.
  7322. * Documentation, converting to plain ASCII: Section 5.2.
  7323. * Documentation, converting to PostScript format: Section 5.3.
  7324. * Documentation, in man page format: Section 5.6.
  7325. * Documentation, in PostScript format: Section 5.4.
  7326. * Documentation, inside source distribution archives: Section 5.5.
  7327. * Documentation, reading: Section 5.1.
  7328. * Documentation, the profiler: Section 13.4.
  7329. * DOS code, using with GCC: Section 17.6.
  7330. * DOS libraries, using with GCC: Section 17.5.
  7331. * DOS object files, using with GCC: Section 17.5.
  7332. * DOS programs, converting to DJGPP: Chapter 17.
  7333. * DOS service calls: Section 18.1.
  7334. * DOS service calls which need buffers: Section 18.2.
  7335. * DOSEmu, incompatibilities with DJGPP: Section 3.4.
  7336. * Downloading DJGPP via e-mail: Section 4.3.
  7337. * Downloading DJGPP with FTP: Section 4.3.
  7338. * Downloading DJGPP with WWW: Section 4.4.
  7339. * DPMI host bugs, might crash DJGPP programs: Section 6.2.
  7340. * DPMI hosts, commercially available: Section 21.2.
  7341. * DPMI services, problems with Novell NWDOS 7: Section 3.1.
  7342. * DPMI services, required to run DJGPP: Section 3.1.
  7343. * DPMI spec, where to get it: Section 22.4.
  7344. * DPMI, required to run DJGPP programs: Section 9.5.
  7345. * Duplicate messages from DJGPP mailing list: Section 20.6.
  7346. * DXE can be debugged with EDEBUG32: Section 12.1.
  7347. * DXE description: Section 22.13.
  7348. * DXE docs and examples: Section 22.13.
  7349. * Dynamically loaded code for DJGPP: Section 22.2.
  7350. * E-mail, downloading DJGPP: Section 4.4.
  7351. * Emulation, floating-point: Chapter 11.
  7352. * Emulator library: Section 11.1.
  7353. * Emulator, floating-point inaccuracies: Section 11.6.
  7354. * Environment size affects spawning child programs: Section 16.5.
  7355. * Environment variables, DJGPP: Section 3.7.
  7356. * Environment variables, linker: Section 8.9.
  7357. * Error messages, redirecting to a file: Section 6.10.
  7358. * Excessive paging, tuning CWSDPMI: Section 3.9.
  7359. * EXE compressor for DJGPP: Section 8.15.
  7360. * Executable size, how to make smaller: Section 8.15.
  7361. * Executable, bloated by static array: Section 8.14.
  7362. * Executable, how to strip off debugging symbols: Section 8.15.
  7363. * FAQ, conversion to different formats: Section 22.17.
  7364. * Far pointer memory access: Section 10.2.
  7365. * Farptr functions, mask off 12 higher bits of address: Section 18.5.
  7366. * Fatal signal, GCC message: Section 6.4.
  7367. * File format not recognized by GCC: Section 8.4.
  7368. * Filename globbing: Section 16.1.
  7369. * Filename globbing, disabling: Section 16.2.
  7370. * Filename wildcards expansion: Section 16.1.
  7371. * Filename wildcards, disabling expansion: Section 16.2.
  7372. * Files, minimum set to download: Section 4.5.
  7373. * Files, reading and writing: Section 9.3.
  7374. * Files, required disk space: Section 4.6.
  7375. * Floating-point emulation: Chapter 11.
  7376. * Floating-point emulation doesn't work: Section 11.1.
  7377. * Floating-point emulation under debugger: Section 12.9.
  7378. * Floating-point emulation, -msoft-float switch: Section 11.4.
  7379. * Floating-point emulation, non-DJGPP emulators: Section 11.2.
  7380. * Floating-point emulation, under OS/2: Section 11.3.
  7381. * Floating-point exception in Objective-C program: Section 11.7.
  7382. * Floating-point issues: Chapter 11.
  7383. * Floating-point math functions, standard and high-quality: Section 8.7.
  7384. * Floating-point, debugger support: Section 12.1.
  7385. * FP_SEG and FP_OFF, porting to DJGPP: Section 17.7.
  7386. * free doesn't change virtual memory: Section 15.2.
  7387. * FTP, downloading DJGPP: Section 4.3.
  7388. * FTP, downloading DJGPP in batch mode: Section 4.7.
  7389. * Functions from libm.a crash with SIGFPE: Section 11.8.
  7390. * Functions, which is in what library: Section 8.8.
  7391. * Game programming, libraries and techniques for DJGPP: Section 22.2.
  7392. * Garbage at end of number, GCC message: Section 22.8.
  7393. * GCC aborts with "Installation problem, cannot exec as": Section 6.4.
  7394. * GCC aborts with "Internal compiler error": Section 6.4.
  7395. * GCC can't recognize file format: Section 8.4.
  7396. * GCC can't recognize source language: Section 8.4.
  7397. * GCC crashes, which subprogram of: Section 6.9.
  7398. * GCC hangs/crashes under Make: Section 6.7.
  7399. * GCC says "Fatal signal X": Section 6.4.
  7400. * Getting DJGPP <1>: Section 4.1.
  7401. * Getting DJGPP: Chapter 4.
  7402. * getting DJGPP from a CD-ROM: Section 4.4.
  7403. * Getting documentation: Section 5.1.
  7404. * Getting more help: Chapter 20.
  7405. * Globbing in filenames: Section 16.1.
  7406. * Globbing in filenames, disabling: Section 16.2.
  7407. * GNU Copyleft, effect on DJGPP: Section 19.1.
  7408. * GNU development utilities, port to DJGPP: Section 22.2.
  7409. * GNU News groups, don't post DJGPP problems: Section 20.1.
  7410. * GNU packages, how to change: Section 22.1.
  7411. * Gopher, downloading DJGPP: Section 4.4.
  7412. * gotoxy doesn't work with `printf': Section 9.4.
  7413. * GPL, effect on DJGPP: Section 19.1.
  7414. * Graphics driver setup: Section 10.1.
  7415. * Graphics issues: Chapter 10.
  7416. * Graphics programs, debugging: Section 12.5.
  7417. * Graphics screen messed up under Windows: Section 10.3.
  7418. * Graphics, direct video access: Section 10.2.
  7419. * Graphics, limitations on Win/NT: Section 3.3.
  7420. * Gurus, asking for help: Section 6.12.
  7421. * Hang, all DJGPP programs: Section 6.2.
  7422. * Hang, DJGPP programs: Chapter 6.
  7423. * harderr function, emulating under DJGPP: Section 22.11.
  7424. * Hardware interrupt handler crashes: Section 18.11.
  7425. * Hardware interrupts, hooking: Section 18.9.
  7426. * Hardware interrupts, subtleties: Section 18.11.
  7427. * Hardware requirements: Chapter 3.
  7428. * Hardware requirements, minimal: Section 3.1.
  7429. * Hardware-oriented programming: Chapter 18.
  7430. * Header files, C++, GCC can't find: Section 8.2.
  7431. * Header files, GCC can't find: Section 8.1.
  7432. * Help, asking for: Section 6.12.
  7433. * HTML format, DJGPP documentation: Section 5.4.
  7434. * I/O speed, DJGPP programs: Section 14.4.
  7435. * i286: Section 3.5.
  7436. * i386SX: Section 3.1.
  7437. * Inaccuracies, using emulator: Section 11.6.
  7438. * Including source code, problems with debugging: Section 12.8.
  7439. * Incompatibilities, i286: Section 3.5.
  7440. * Incompatibilities, Linux DOSEmu: Section 3.4.
  7441. * Incompatibilities, OS/2: Section 3.2.
  7442. * Incompatibilities, Warp: Section 3.2.
  7443. * Incompatibilities, Windows/NT: Section 3.3.
  7444. * Info won't display a file:             Info can't find ``Top''.
  7445. * Inline assembly, how to write: Section 18.13.
  7446. * Inline functions, linker won't find: Section 8.10.
  7447. * inp function: Section 18.12.
  7448. * Int 24h crashes DJGPP programs: Section 22.11.
  7449. * int86 crashes program: Section 18.1.
  7450. * int86x/intdosx, how to pass a buffer: Section 18.2.
  7451. * intdos crashes program: Section 18.1.
  7452. * Intel vs AT&T assembly syntax: Section 17.1.
  7453. * Intel-style assembly code, using with DJGPP: Section 17.3.
  7454. * Interactive programs, screen I/O: Section 9.4.
  7455. * Internal compiler error, when compiling C++ programs: Section 6.4.
  7456. * Interrupt 24h handling: Section 22.11.
  7457. * Interrupt chaining: Section 18.9.
  7458. * Interrupt frequency, maximum: Section 18.11.
  7459. * Interrupt handlers, locking memory: Section 18.11.
  7460. * Interrupt reflection: Section 18.9.
  7461. * Interrupt reflection overhead: Section 18.11.
  7462. * Interrupts handlers in DJGPP: Section 18.9.
  7463. * Invoking v2 programs from v1.x programs: Section 22.12.
  7464. * Keyboard interrupt cannot be hooked under debugger: Section 12.9.
  7465. * Keystrokes don't get to keyboard handler: Section 18.11.
  7466. * Known bugs in DJGPP, how to browse: Section 22.1.
  7467. * ldexp crashes programs with FP exception: Section 11.8.
  7468. * Legal aspects of DJGPP programming: Chapter 19.
  7469. * Legal restrictions on DJGPP apps: Section 19.1.
  7470. * Legal restrictions, DJGPP utilities: Section 19.2.
  7471. * Length of command line: Section 16.5.
  7472. * Letter case in filenames submitted to GCC: Section 8.4.
  7473. * LFN API, not supported on Win/NT: Section 3.3.
  7474. * LFN problems: Section 22.14.
  7475. * LGPL, effect on DJGPP: Section 19.1.
  7476. * libc2.tex, missing file: Section 5.3.
  7477. * Libraries, converting to DJGPP: Chapter 17.
  7478. * Libraries, GCC can't find: Section 8.1.
  7479. * Libraries, optional, how to link: Section 8.7.
  7480. * Libraries, order on compilation/link command line: Section 8.9.
  7481. * Libraries, searching for functions: Section 8.8.
  7482. * Library docs, missing libc2.tex: Section 5.3.
  7483. * Library docs, problems in generating printed version: Section 5.3.
  7484. * Library functions, C++, linker won't find: Section 8.10.
  7485. * Library functions, linker won't find: Section 8.7.
  7486. * Library functions, linker won't find in non-default directories: Section 8.9.
  7487. * Library functions, linker won't find, libraries' order: Section 8.9.
  7488. * Library, floating-point emulation: Section 11.1.
  7489. * Linear address, mask off 12 higher bits: Section 18.5.
  7490. * Linear frame buffer access: Section 10.2.
  7491. * Link-time problems: Chapter 8.
  7492. * Linker fails because of Win95 shortcut files: Section 8.16.
  7493. * Linker fails for a.out files in a library: Section 8.18.
  7494. * Linker fails for large libraries or object files: Section 8.18.
  7495. * Linker fails for obj files converted by EMXAOUT: Section 8.18.
  7496. * Linker fails to find crt0.o under Novell: Section 8.1.
  7497. * Linker fails to produce executable under Novell: Section 8.17.
  7498. * Linker speed: Chapter 7.
  7499. * linker won't find djgpp_first_dtor symbol: Section 8.13.
  7500. * Linking C++ programs, use the GXX driver: Section 8.7.
  7501. * Linking programs, unresolved C++ library functions: Section 8.10.
  7502. * Linking programs, unresolved library functions: Section 8.7.
  7503. * Linking programs, unresolved library functions, libraries' order: Section 8.9.
  7504. * Linking speed, improve by stub-editing ld.exe: Section 7.2.
  7505. * Links, symbolic, simulation with DJGPP: Section 22.3.
  7506. * Linux-to-DOS cross-compiling with DJGPP: Section 22.7.
  7507. * List of DJGPP packages: Section 4.5.
  7508. * Locking memory for hardware interrupt handlers: Section 18.9.
  7509. * Locking memory for interrupt handlers: Section 18.11.
  7510. * Long command lines: Section 16.4.
  7511. * Long command lines, from Makefile: Section 16.6.
  7512. * Long command lines, maximum length: Section 16.5.
  7513. * long filename support, bugs: Section 22.14.
  7514. * Long Filenames aren't supported on Win/NT: Section 3.3.
  7515. * Long filenames in setting DJGPP env. variable: Section 8.1.
  7516. * Low-level programming issues: Chapter 18.
  7517. * Machines with low extended RAM, tuning CWSDPMI: Section 3.9.
  7518. * Makefile, first character of every command must be TAB: Section 22.15.
  7519. * Makefile, passing long command lines: Section 16.6.
  7520. * Makefiles with long command lines: Section 16.4.
  7521. * malloc doesn't change virtual memory: Section 15.2.
  7522. * malloc fails under EMM386 or HIMEM: Section 15.7.
  7523. * malloc fails under QDPMI or Windows: Section 15.4.
  7524. * malloc fails under Windows 3.x: Section 15.5.
  7525. * malloc fails under Windows 95: Section 15.6.
  7526. * malloc, effect on "Fat DS": Section 18.6.
  7527. * Man pages, how to read: Section 5.6.
  7528. * Math functions crash with SIGFPE: Section 11.8.
  7529. * Maximum interrupt frequency: Section 18.11.
  7530. * Maximum length of command line: Section 16.5.
  7531. * Memory allocation fails under EMM386 or HIMEM: Section 15.7.
  7532. * Memory allocation fails under QDPMI or Windows 95: Section 15.4.
  7533. * Memory allocation fails under Windows 3.x: Section 15.5.
  7534. * Memory allocation fails under Windows 95: Section 15.6.
  7535. * Memory at run time: Chapter 15.
  7536. * Memory locking for hardware interrupt handlers: Section 18.9.
  7537. * Memory manager, settings for optimal performance: Section 3.9.
  7538. * Memory size reported by go32-v2: Section 4.6.
  7539. * Memory, how much is left for spawned programs: Section 15.8.
  7540. * Memory, virtual, failure to allocate: Section 15.3.
  7541. * Memory, virtual, free doesn't change: Section 15.2.
  7542. * Memory, virtual, malloc doesn't change: Section 15.2.
  7543. * Memory, virtual, maximum available: Section 15.1.
  7544. * Memory, virtual, QDPMI failure: Section 15.3.
  7545. * Memory-mapped devices above 1MB: Section 18.7.
  7546. * Memory-mapped devices, accessing with dedicated selector: Section 18.4.
  7547. * Memory-mapped devices, fast access: Section 18.6.
  7548. * Memory-mapped devices, moving data to/from: Section 18.4.
  7549. * Method name in C++, how to pass to GDB: Section 12.7.
  7550. * Minimal hardware requirements: Section 3.1.
  7551. * Minimum system RAM: Section 3.1.
  7552. * Minimum system RAM, CWSDPMI: Section 3.1.
  7553. * Missing C++ header files: Section 8.2.
  7554. * Missing crt0.o: Section 8.1.
  7555. * Missing header files: Section 8.1.
  7556. * Missing libraries: Section 8.1.
  7557. * Missing separator, Make error message: Section 22.15.
  7558. * Mixing v2.0 GCC with CC1PLUS from v1.x, Unknown filetype message.: Section 6.5.
  7559. * Mixing v2.x Make with v1.x programs hangs the machine: Section 6.7.
  7560. * MK_FP macro, porting to DJGPP: Section 17.7.
  7561. * Mode switches, effect on program speed: Section 14.1.
  7562. * Monochrome monitor, redirecting screen output: Section 12.5.
  7563. * More help, how to get: Chapter 20.
  7564. * Motorola 68K targets, cross-compiling with DJGPP: Section 22.7.
  7565. * Mouse handler, how to install with DJGPP: Section 18.8.
  7566. * movedata, mask off 12 higher bits of address: Section 18.5.
  7567. * Moving data to and from conventional memory: Section 18.4.
  7568. * Moving data to and from transfer buffer: Section 18.4.
  7569. * MS-Windows header file windows.h, where to get it: Section 3.6.
  7570. * MS-Windows programming under DJGPP: Section 3.6.
  7571. * Nearptr functions: Section 18.6.
  7572. * Nearptr functions, mask off 12 higher bits of address: Section 18.5.
  7573. * nearptr method of direct memory access: Section 18.4.
  7574. * Nested programs, how much memory is left: Section 15.8.
  7575. * Network installation makes linking slow: Section 7.2.
  7576. * New features in v2: Section 21.1.
  7577. * No DPMI error message: Section 6.1.
  7578. * No free XMS memory when NOEMS parameter is used: Section 15.8.
  7579. * No messages from the mailing list: Section 20.5.
  7580. * Non-DJGPP floating-point emulators: Section 11.2.
  7581. * Not COFF error message from DJGPP programs: Section 6.5.
  7582. * Novell NDOS, buggy DPMI services crash DJGPP: Section 6.2.
  7583. * Novell, linker or STUBIFY don't produce executable: Section 8.17.
  7584. * Null pointer dereference crashes v2.0 programs: Section 9.1.
  7585. * Numeric exception, program crash: Section 11.5.
  7586. * Objective C, compiling: Section 8.5.
  7587. * Objective-C programs crash with FP exception: Section 11.7.
  7588. * Old CWSDPMI, influence on compilation speed: Section 7.1.
  7589. * Optimal performance, CWSDPMI tuning: Section 3.9.
  7590. * Optimal performance, disk cache settings: Section 3.9.
  7591. * Optimal performance, RAM disk settings: Section 3.9.
  7592. * Optimal performance, system configuration: Section 3.9.
  7593. * Optimization crashes GCC: Section 6.3.
  7594. * Optimizing DJGPP programs: Section 13.1.
  7595. * outp function: Section 18.12.
  7596. * Overhead, interrupt reflection to protected mode: Section 18.11.
  7597. * Packages, DJGPP, list of: Section 4.5.
  7598. * Packages, ported to DJGPP: Section 22.2.
  7599. * Packages, required disk space: Section 4.6.
  7600. * Packages, which to download: Section 4.5.
  7601. * Packed structs, C++ bug: Section 22.10.
  7602. * Packing the structs: Section 22.9.
  7603. * Page fault error message from CWSDPMI: Section 9.1.
  7604. * Paging starts before all RAM is used: Section 15.7.
  7605. * Peek/poke absolute address: Section 18.4.
  7606. * Pentium-optimized code: Section 14.3.
  7607. * Performance issues: Chapter 14.
  7608. * Peripheral devices above 1MB: Section 18.7.
  7609. * Peripheral devices, fast access: Section 18.6.
  7610. * Peripheral devices, reading/writing ports: Section 18.12.
  7611. * Peripherals, moving data to/from: Section 18.4.
  7612. * Pi, accurate computation: Section 11.6.
  7613. * Port reading/writing: Section 18.12.
  7614. * Ported programs run much slower: Section 14.5.
  7615. * Posting problems, not to GNU News groups: Section 20.1.
  7616. * Posting to DJGPP mailing list: Section 20.2.
  7617. * PostScript documentation: Section 5.3.
  7618. * PostScript documentation, ready-to-print: Section 5.4.
  7619. * Pre-processor symbols, DJGPP-specific: Section 8.6.
  7620. * printf cannot print color text: Section 9.4.
  7621. * Printing DJGPP documentation: Section 5.3.
  7622. * Problems with DJGPP programs: Chapter 6.
  7623. * Problems, asking for help: Section 6.12.
  7624. * Problems, searching for solution in DJGPP archives: Section 6.11.
  7625. * Profiled programs crash under debugger: Section 12.9.
  7626. * Profiler documentation: Section 13.4.
  7627. * Profiler produces no output: Section 13.6.
  7628. * Profiling DJGPP programs: Section 13.1.
  7629. * Profiling DJGPP programs, need COFF output: Section 13.3.
  7630. * Profiling issues: Chapter 13.
  7631. * Profiling programs that terminate abnormally: Section 13.6.
  7632. * Profiling, library routines: Section 13.5.
  7633. * Program crashes accessing empty floppy/CD-ROM drives: Section 22.11.
  7634. * Program crashes because of Int 24h: Section 22.11.
  7635. * Program crashes in int86/intdos: Section 18.1.
  7636. * Program crashes in v2.0, but not in v1.x: Section 9.1.
  7637. * Program crashes while allocating memory: Section 15.4.
  7638. * Programs crash when compiled for profiling: Section 13.2.
  7639. * Programs crash with SIGSEGV due to small stack size: Section 15.9.
  7640. * Programs crash, general troubleshooting: Section 6.9.
  7641. * Programs crash, numeric exception: Section 11.5.
  7642. * Programs crash, saving debugging output: Section 6.10.
  7643. * Programs crash, searching DJGPP archives: Section 6.11.
  7644. * Programs that exit abnormally, how to profile: Section 13.6.
  7645. * Programs using nearptr fail on Windows/NT: Section 3.3.
  7646. * Protected mode and converted assembly code: Section 17.4.
  7647. * Protected-mode interrupt vector: Section 18.9.
  7648. * Pseudo-register variables, porting to DJGPP: Section 17.8.
  7649. * QEMM auto/off mode, conflicts with DJGPP: Section 6.6.
  7650. * Quotes, how to pass them to programs: Section 16.3.
  7651. * RAM disk, influence on compilation speed: Section 7.1.
  7652. * RAM disk, recommended settings: Section 3.9.
  7653. * RAM disk, when compiling large programs: Section 3.8.
  7654. * RCS port to DJGPP: Section 22.2.
  7655. * Read DJGPP traffic via WWW: Section 20.4.
  7656. * Reading an int from a binary file: Section 22.9.
  7657. * Reading documentation: Section 5.1.
  7658. * Reading documentation with a Web browser: Section 5.2.
  7659. * Reading documentation with text editor/viewer: Section 5.2.
  7660. * Reading documentation, converting to plain ASCII: Section 5.2.
  7661. * Reading structs from disk files: Section 22.9.
  7662. * Real-mode call-back: Section 18.8.
  7663. * Real-mode interrupt vector: Section 18.9.
  7664. * Real-mode services, calling DJGPP functions: Section 18.8.
  7665. * realloc, effect on "Fat DS": Section 18.6.
  7666. * Reboot, every DJGPP program: Section 6.2.
  7667. * Reboot, when running DJGPP programs: Chapter 6.
  7668. * Recommended system RAM, for C programs compilation: Section 3.1.
  7669. * Recommended system RAM, for C++ programs compilation: Section 3.1.
  7670. * Recompiling GCC: Section 22.1.
  7671. * Redirecting GCC messages to a file: Section 6.10.
  7672. * Redirection in Makefile, effect on long command lines: Section 16.6.
  7673. * Redirection, using the REDIR program: Section 16.6.
  7674. * Required hardware, general: Chapter 3.
  7675. * Response file, passing long command lines: Section 16.4.
  7676. * Run-time environment in v2.x: Section 21.2.
  7677. * Run-time performance: Chapter 14.
  7678. * Run-time problems: Chapter 9.
  7679. * Runtime speed, slower in v2.x: Section 14.2.
  7680. * sbrk, effect on "Fat DS": Section 18.6.
  7681. * Screen contents not restored under Windows: Section 10.3.
  7682. * Screen I/O: Section 9.4.
  7683. * Searching DJGPP archives: Section 6.11.
  7684. * setvbuf, effect on I/O speed: Section 14.4.
  7685. * SHELL= variable in Makefile, effect on long command lines: Section 16.6.
  7686. * Shortcut files under Win95 fail DJGPP linker: Section 8.16.
  7687. * Signals in debugged programs: Section 12.9.
  7688. * SimTel mirrors' list: Section 4.1.
  7689. * Single-stepping doesn't work in GDB on Windows 3.x: Section 12.9.
  7690. * Single-stepping doesn't work in RHIDE on Windows 3.x: Section 12.9.
  7691. * Size of a struct under DJGPP: Section 22.9.
  7692. * Slow code, due to bad alignment by GAS: Section 14.3.
  7693. * Slow compilation: Section 7.1.
  7694. * Slow compilation, tuning CWSDPMI: Section 3.9.
  7695. * Slow linking, possible reasons: Section 7.2.
  7696. * Slow-down, programs ported from other compilers: Section 14.5.
  7697. * Software interrupts, need zero SS, SP and FLAGS: Section 18.3.
  7698. * Solved problems, searching in DJGPP archives: Section 6.11.
  7699. * Sound Blaster code for DJGPP: Section 22.2.
  7700. * Source files, using as the best docs: Section 5.7.
  7701. * Source language is not recognized by GDB in C++ programs: Section 12.7.
  7702. * Spawned programs, how much memory is left: Section 15.8.
  7703. * Spawning child processes, OS/2: Section 3.2.
  7704. * Spawning child programs on Windows/NT and 95: Section 3.3.
  7705. * Spawning programs, effect of environment size: Section 16.5.
  7706. * Spawning v2 programs from v1.x programs: Section 22.12.
  7707. * Spawning v2.x programs from v1.x programs doesn't work: Section 6.7.
  7708. * Speed of compilation: Section 7.1.
  7709. * Stack dump, how to read: Section 9.2.
  7710. * Stack overflow under debugger: Section 15.9.
  7711. * Stack size under DJGPP: Section 15.9.
  7712. * Stack size, insufficient, causes programs to crash: Section 15.9.
  7713. * Stand-alone DJGPP programs that don't need DPMI: Section 9.5.
  7714. * Standard output/error stream, redirecting to a file: Section 6.10.
  7715. * Static array enlarges C++ executable: Section 8.14.
  7716. * STL library, not in lgp271b distribution: Section 8.7.
  7717. * struct reading from a disk file: Section 22.9.
  7718. * Struct, size in bytes under DJGPP: Section 22.9.
  7719. * Structure packing, C++ bug: Section 22.10.
  7720. * Structure padding: Section 22.9.
  7721. * Subscription to DJGPP mailing list: Section 20.3.
  7722. * Subsidiary programs, how much memory is left: Section 15.8.
  7723. * SVGA types supported by GRX: Section 10.1.
  7724. * Symbolic links, simulation with DJGPP: Section 22.3.
  7725. * System configuration, the best: Section 3.7.
  7726. * System RAM, minimum: Section 3.1.
  7727. * Systems programming issues: Chapter 18.
  7728. * TAB, must be the first character of every command: Section 22.15.
  7729. * TABs replaced with spaces by a text editor: Section 22.15.
  7730. * TCP/IP library for DJGPP: Section 22.2.
  7731. * Text-mode video memory access: Section 10.2.
  7732. * Timer interrupts code for DJGPP: Section 22.2.
  7733. * Traceback, how to read: Section 9.2.
  7734. * Tracing compilation progress with -Q: Section 6.3.
  7735. * Transfer buffer, mask off 12 higher bits of address: Section 18.5.
  7736. * Transfer buffer, moving data: Section 18.4.
  7737. * Transfer buffer, use when debugging: Section 12.4.
  7738. * Transfer buffer, using to call DOS/BIOS: Section 18.2.
  7739. * Tuning CWSDPMI for optimal performance: Section 3.9.
  7740. * Turbo Vision, DJGPP port: Section 22.2.
  7741. * TZ database updates, where to get: Section 22.16.
  7742. * TZ variable, how to set: Section 22.16.
  7743. * Uninitialized memory crashes v2.0 programs: Section 9.1.
  7744. * Unix-like sbrk algorithm considered harmful for HW interrupts: Section 18.11.
  7745. * Unix-to-DOS cross-compiling with DJGPP: Section 22.7.
  7746. * Unknown filetype, GCC message: Section 6.5.
  7747. * Unresolved __pure_virtual function in C++: Section 8.12.
  7748. * Unresolved externals: Section 8.7.
  7749. * Unresolved externals in C++ programs, use GXX: Section 8.7.
  7750. * Unresolved externals, C++: Section 8.10.
  7751. * unresolved externals, djgpp_first_ctor: Section 8.13.
  7752. * Unsubscribing from the DJGPP mailing list: Section 20.4.
  7753. * Unsupported DOS request message: Section 18.1.
  7754. * Unsupported INT message: Section 18.1.
  7755. * Uploading DJGPP software: Section 22.6.
  7756. * v2 code slower than v1.x: Section 14.2.
  7757. * V2, new features and bug fixes: Chapter 21.
  7758. * v2.0, program crashes: Section 9.1.
  7759. * v2.01 code slower than v2.0: Section 14.2.
  7760. * V2.x, new environment: Section 21.2.
  7761. * V86 mode, QEMM and CWSDPMI problems: Section 6.6.
  7762. * VBE 2.0 linear frame buffer access: Section 10.2.
  7763. * VESA support by GRX: Section 10.1.
  7764. * VGA Mode-X graphics for DJGPP: Section 22.2.
  7765. * Video memory, direct access: Section 10.2.
  7766. * Virtual memory: Chapter 15.
  7767. * Virtual memory exhausted, during compilation: Section 6.3.
  7768. * Virtual memory under Windows 95: Section 15.6.
  7769. * Virtual memory, failure to allocate: Section 15.3.
  7770. * Virtual memory, free doesn't change: Section 15.2.
  7771. * Virtual memory, how to disable it for CWSDPMI: Section 7.1.
  7772. * Virtual memory, malloc doesn't change: Section 15.2.
  7773. * Virtual memory, maximum available: Section 15.1.
  7774. * Virtual memory, QDPMI failure: Section 15.3.
  7775. * Virus infection cause "Not COFF" message: Section 6.5.
  7776. * Watchpoints don't work in GDB under Windows: Section 12.9.
  7777. * Web site for DJGPP: Section 22.5.
  7778. * Weekly digest, problems in receiving: Section 20.3.
  7779. * Wildcards expansion: Section 16.1.
  7780. * Wildcards expansion, disabling: Section 16.2.
  7781. * Win32 programming with GCC: Section 3.6.
  7782. * Windows applications with DJGPP: Section 3.6.
  7783. * WinNT/Win95 programming with Cygnus GCC port: Section 3.6.
  7784. * WWW services for DJGPP: Section 22.5.
  7785. * WWW, downloading DJGPP: Section 4.4.
  7786. * X emulation for DJGPP: Section 22.2.
  7787. * Zoneinfo directory: Section 22.16.
  7788.  
  7789. 25. Program Index
  7790. *****************
  7791.  
  7792.   This index lists the problems and solutions by the program/package to which
  7793. they pertain.  If you know what program or package gives you the trouble,
  7794. look it up here.
  7795.  
  7796.  
  7797.  
  7798. * 386Max, how to ensure virtual memory: Section 15.3.
  7799. * 386Max, speeding up DJGPP start-up: Section 15.3.
  7800. * 4DOS, redirecting GCC messages to a file: Section 6.10.
  7801. * _control87, change coprocessor setup: Section 11.5.
  7802. * _crt0_startup_flags settings and QDPMI: Section 15.3.
  7803. * _crt0_startup_flags, setting to lock memory: Section 18.11.
  7804. * _crt0_startup_flags, Unix sbrk is incompatible with HW interrupts: Section 18.11.
  7805. * _string.h, GCC can't find: Section 8.2.
  7806. * AutoWinNet, automated downloading: Section 4.7.
  7807. * BatchFTP, automated downloading from a Unix box: Section 4.7.
  7808. * BCCBGI (from BCC2GRX) crashes with the default stack: Section 15.9.
  7809. * Bison doesn't imply GPL/LGPL: Section 19.1.
  7810. * Bison, debugging generated code: Section 12.8.
  7811. * C compiler overflows its stack for large programs: Section 6.4.
  7812. * C++ class libraries, legal restrictions: Section 19.1.
  7813. * C++ compiler crashes for large programs: Section 15.9.
  7814. * C++ compiler overflows its stack for large programs: Section 6.4.
  7815. * Cawf, using to read man pages: Section 5.6.
  7816. * CC1PLUS crashes with SIGSEGV: Section 15.9.
  7817. * CHCP DOS command might prevent MSHELL from working: Section 12.5.
  7818. * complex.h functions, linker can't find: Section 8.10.
  7819. * Complex.h, GCC can't find: Section 8.2.
  7820. * CPP, compiling, memory requirements: Section 3.8.
  7821. * CPP, compiling, RAM disk: Section 3.9.
  7822. * CTRL87, control numeric exceptions: Section 11.5.
  7823. * CWSDPMI allows "Fat DS": Section 18.6.
  7824. * CWSDPMI crashes programs allocating memory is small chunks: Section 15.4.
  7825. * CWSDPMI crashes programs which dereference NULL pointers: Section 9.1.
  7826. * CWSDPMI doesn't support hooking Int 24h: Section 22.11.
  7827. * CWSDPMI runs out of virtual memory: Section 6.4.
  7828. * CWSDPMI, alternative DPMI hosts: Section 21.2.
  7829. * CWSDPMI, disabling virtual memory: Section 7.1.
  7830. * CWSDPMI, legal restrictions: Section 19.2.
  7831. * CWSDPMI, maximum available virtual memory: Section 15.1.
  7832. * CWSDPMI, memory usage for nested programs: Section 15.8.
  7833. * CWSDPMI, minimum required system RAM: Section 3.1.
  7834. * CWSDPMI, old (beta) versions slow-down compilation: Section 7.1.
  7835. * CWSDPMI, pages too early under EMM386: Section 15.7.
  7836. * CWSDPMI, problems with QEMM auto/off mode: Section 6.6.
  7837. * CWSDPMI, setting parameters for optimal performance: Section 3.9.
  7838. * CWSDPMI, should be distributed with DJGPP programs: Section 9.5.
  7839. * CWSDPR0 reduces interrupt reflection overhead: Section 18.11.
  7840. * CWSDPR0, use for testing HW interrupt handlers: Section 18.9.
  7841. * CWSPARAM, a program to tune CWSDPMI performance: Section 3.9.
  7842. * DJGPP.ENV syntax explained: Section 8.1.
  7843. * DJGPP.ENV, beware of blanks when setting: Section 8.1.
  7844. * DJGPP.ENV, compiler environment variables: Section 8.1.
  7845. * DJGPP.ENV, linker environment variables: Section 8.9.
  7846. * DJP compressor supports DLM: Section 8.15.
  7847. * DJP, an executable compressor for DJGPP: Section 8.15.
  7848. * DLM compression, with DJP: Section 8.15.
  7849. * DLM, a facility to load code at run time: Section 22.2.
  7850. * DOSEMU doesn't allow "Fat DS": Section 18.6.
  7851. * EDEBUG32 can debug a DXE: Section 12.1.
  7852. * EMACS can be compiled with DJGPP: Section 22.2.
  7853. * Emacs, reading docs: Section 5.1.
  7854. * Emacs, reading Info files: Section 5.1.
  7855. * Emacs, using to read man pages: Section 5.6.
  7856. * EMM386, cannot use all free memory: Section 15.7.
  7857. * EMM386, effect on max interrupt frequency: Section 18.11.
  7858. * EMM386, malloc/calloc fails: Section 15.7.
  7859. * EMM386, settings for optimal performance: Section 3.9.
  7860. * emTeX, printing the docs: Section 5.3.
  7861. * emu387.dxe, distribution with DJGPP programs: Section 11.1.
  7862. * EMX/GCC, writing Windows applications: Section 3.6.
  7863. * EMXAOUT converter from .obj to COFF format: Section 17.5.
  7864. * EMXAOUT output can't be put into a library: Section 17.5.
  7865. * EMXAOUT produces a.out format: Section 17.5.
  7866. * F2C, debugging generated code: Section 12.8.
  7867. * Flex doesn't imply GPL/LGPL: Section 19.1.
  7868. * Flex, debugging generated code: Section 12.8.
  7869. * FSDB crashes under QEMM/QDPMI: Section 12.2.
  7870. * FSDB, the full-screen debugger: Section 12.1.
  7871. * Gas can introduce errors into assembly code: Section 17.2.
  7872. * GCC can't find C++ headers: Section 8.2.
  7873. * GCC can't find crt0.o: Section 8.1.
  7874. * GCC can't find headers: Section 8.1.
  7875. * GCC can't find libraries: Section 8.1.
  7876. * GCC cannot resolve djgpp_first_ctor symbol when linking: Section 8.13.
  7877. * GCC crashes during optimization: Section 6.3.
  7878. * GCC crashes, which subprogram of: Section 6.9.
  7879. * GCC doesn't pack structs in C++ programs: Section 22.10.
  7880. * GCC doesn't recognize .lib libraries: Section 17.5.
  7881. * GCC doesn't recognize .obj object files: Section 17.5.
  7882. * GCC doesn't recognize file format: Section 8.4.
  7883. * GCC exhausts virtual memory: Section 6.3.
  7884. * GCC from v2.x crashes under v1.x Make: Section 6.7.
  7885. * GCC hangs under Make: Section 6.7.
  7886. * GCC says "garbage at end of number": Section 22.8.
  7887. * GCC won't compile C++-style comments in C programs: Section 8.3.
  7888. * GCC won't find inline functions without -O: Section 8.10.
  7889. * GCC, -fconserve-space switch: Section 8.14.
  7890. * GCC, -msoft-float switch: Section 11.4.
  7891. * GCC, -v switch shows the compilation passes: Section 8.4.
  7892. * GCC, assumes C++ source is .cc: Section 12.6.
  7893. * GCC, code efficiency: Section 14.1.
  7894. * GCC, compiling for debugging: Section 12.1.
  7895. * GCC, compiling, memory requirements: Section 3.8.
  7896. * GCC, compiling, RAM disk: Section 3.9.
  7897. * GCC, environment variables: Section 8.1.
  7898. * GCC, file source language recognition: Section 8.4.
  7899. * GCC, I/O speed: Section 14.4.
  7900. * GCC, inline assembly facilities: Section 18.13.
  7901. * GCC, maximum length of command line in Makefiles: Section 16.5.
  7902. * GCC, passing long command lines via Makefile: Section 16.6.
  7903. * GCC, recompiling: Section 22.1.
  7904. * GCC, redirecting messages to a file: Section 6.10.
  7905. * GCC, slow compilation: Section 7.1.
  7906. * GDB cannot restart the debuggee: Section 12.1.
  7907. * GDB causes stack overflow in a debuggee: Section 15.9.
  7908. * GDB crashes under QEMM/QDPMI: Section 12.2.
  7909. * GDB doesn't pass command-line arguments to debuggee: Section 12.1.
  7910. * GDB doesn't recognize source language: Section 12.7.
  7911. * GDB GP Faults on breakpoint/watchpoint under Windows: Section 12.9.
  7912. * GDB needs COFF output: Section 12.3.
  7913. * GDB, conflicts with file redirection: Section 12.1.
  7914. * GDB, debugging DJGPP programs: Section 12.1.
  7915. * GDB, debugging graphics programs: Section 12.5.
  7916. * GDB, how is it different on MS-DOS: Section 12.1.
  7917. * GDB, how to use C++ class variables' names: Section 12.7.
  7918. * GDB, how to use C++ method names: Section 12.7.
  7919. * GDB, init file name: Section 12.1.
  7920. * GDB, name of the READLINE init file: Section 12.1.
  7921. * GDB, slow loading of symbols and sources: Section 12.1.
  7922. * go32-v2 reports the amount of memory and swap space: Section 4.6.
  7923. * go32-v2 usage: Section 22.12.
  7924. * go32-v2, use to find out how much memory is available to DJGPP: Section 15.7.
  7925. * Gprof cannot find program: Section 13.3.
  7926. * Gprof documentation: Section 13.4.
  7927. * gprof produces no output: Section 13.6.
  7928. * Gprof says "bad format": Section 13.3.
  7929. * Gprof, documentation: Section 5.5.
  7930. * Gprof, the GNU profiler: Section 13.1.
  7931. * Groff, port to DJGPP: Section 5.6.
  7932. * Groff, using to read man pages: Section 5.6.
  7933. * GRX, supported SVGA types: Section 10.1.
  7934. * gxx driver, not in gcc272b distribution: Section 8.7.
  7935. * gxx driver, searches C++ libraries automatically: Section 8.7.
  7936. * HIMEM, malloc/calloc fails: Section 15.7.
  7937. * INFNG, produces the FAQ in Norton Guides format: Section 22.17.
  7938. * Info crashes due to ^Z or whitespace at end of DJGPP.ENV: Section 6.2.
  7939. * Info crashes under QDPMI: Section 6.2.
  7940. * Info won't display a file:             Info can't find ``Top''.
  7941. * Info, a stand-alone docs browser: Section 5.1.
  7942. * Info, using to read man pages: Section 5.6.
  7943. * iostream functions, linker can't find: Section 8.10.
  7944. * iostream library, why use it: Section 8.7.
  7945. * iostream.h, GCC can't find: Section 8.2.
  7946. * LaTeX, printing the docs: Section 5.3.
  7947. * ld fails for a.out files in a library: Section 8.18.
  7948. * ld fails for large libraries and object files: Section 8.18.
  7949. * ld fails for obj files converted by EMXAOUT: Section 8.18.
  7950. * LD linker, linker script defines djgpp_first_ctor: Section 8.13.
  7951. * ld, how to improve linking speed: Section 7.2.
  7952. * Less, using to read man pages: Section 5.6.
  7953. * Lex, debugging generated code: Section 12.8.
  7954. * libemu.a FP emulation library: Section 11.1.
  7955. * libg++ library: Section 8.7.
  7956. * libgpp library: Section 8.7.
  7957. * libgpp.a, legal restrictions: Section 19.1.
  7958. * libiostream.a, legal restrictions: Section 19.1.
  7959. * libstdc++ standard templates library: Section 8.7.
  7960. * Linker can't find library functions: Section 8.7.
  7961. * Linker can't find library functions in non-default directories: Section 8.9.
  7962. * Linker can't find some C++ library functions: Section 8.10.
  7963. * Linker, environment variables: Section 8.9.
  7964. * Linker, how to get COFF output: Section 12.3.
  7965. * Linker, order of libraries in the command line: Section 8.9.
  7966. * Linking against optional libraries: Section 8.7.
  7967. * Linux doesn't allow "Fat DS": Section 18.6.
  7968. * Linux, compatibility: Section 3.1.
  7969. * Linux, needs a patch to run nested programs: Section 3.4.
  7970. * Make crashes on DOSEmu: Section 3.4.
  7971. * Make crashes on OS/2: Section 3.2.
  7972. * Make error message "missing separator": Section 22.15.
  7973. * Make requires floating point: Section 22.1.
  7974. * Make, GCC hangs when invoked from it: Section 6.7.
  7975. * Make, maximum length of command line to pass to GCC: Section 16.5.
  7976. * Make, passing long command lines via Makefile: Section 16.6.
  7977. * Makeinfo, using to convert Info files to plain ASCII: Section 5.2.
  7978. * MAKERTF, produces the FAQ in RTF format: Section 22.17.
  7979. * Man program for DJGPP docs: Section 5.6.
  7980. * math library, default ANSI/ISO and high-quality functions: Section 8.7.
  7981. * More, using to read man pages: Section 5.6.
  7982. * Mosaic, downloading DJGPP: Section 4.4.
  7983. * MSHELL fails because of TSR programs: Section 12.5.
  7984. * MSHELL, redirecting screen output: Section 12.5.
  7985. * NASM, a portable assembler with Intel syntax support: Section 17.3.
  7986. * NDOS, buggy DPMI services crash DJGPP: Section 6.2.
  7987. * Netscape, downloading DJGPP: Section 4.4.
  7988. * NM, printing library contents: Section 8.8.
  7989. * Novell 3.x, linker doesn't find crt0.o: Section 8.1.
  7990. * Novell NWDOS 7, buggy DPMI services: Section 3.1.
  7991. * Novell NWDOS 7, compatibility: Section 3.1.
  7992. * NWDOS, buggy DPMI services crash DJGPP: Section 6.2.
  7993. * OBJ2COFF converter from .obj to COFF format: Section 17.5.
  7994. * OBJ2COFF, commercial use is prohibited: Section 17.5.
  7995. * OBJDUMP segment overrides bugs: Section 17.2.
  7996. * Objective C, compilation problems: Section 8.5.
  7997. * Objective-C, cannot run on machines without FPU: Section 11.7.
  7998. * obstack package: Section 8.7.
  7999. * OpenDOS, bug in DPMI services crash DJGPP: Section 6.2.
  8000. * OS/2 Warp allows "Fat DS": Section 18.6.
  8001. * OS/2, compatibility: Section 3.1.
  8002. * OS/2, floating point emulation: Section 11.3.
  8003. * OS/2, incompatibilities: Section 3.2.
  8004. * PMODE/DJ reduces interrupt reflection overhead: Section 18.11.
  8005. * PMODE/DJ, can be used to produce stand-alone programs: Section 9.5.
  8006. * POVRAY, linker fails to link the library: Section 8.18.
  8007. * Q87, an emulator compatible with DJGPP: Section 11.2.
  8008. * QDPMI allows "Fat DS": Section 18.6.
  8009. * QDPMI and _crt0_startup_flags settings: Section 15.3.
  8010. * QDPMI crashes debugger: Section 12.2.
  8011. * QDPMI crashes DJGPP programs when they cause Int 24h: Section 22.11.
  8012. * QDPMI crashes Info: Section 6.2.
  8013. * QDPMI fails to provide virtual memory: Section 15.3.
  8014. * QDPMI, how to disable: Section 12.2.
  8015. * QDPMI, malloc/calloc failure: Section 15.4.
  8016. * QDPMI, memory usage for nested programs: Section 15.8.
  8017. * QEMM crashes debugger: Section 12.2.
  8018. * QEMM, auto/off mode, conflicts with CWSDPMI: Section 6.6.
  8019. * QEMM386, settings for optimal performance: Section 3.9.
  8020. * RCS port to DJGPP: Section 22.2.
  8021. * REDIR, redirecting GCC messages to a file: Section 6.10.
  8022. * REDIR, redirecting stack dump to a file: Section 9.2.
  8023. * REDIR, use to get redirection and long command lines: Section 16.6.
  8024. * regex package from GNU: Section 8.7.
  8025. * Regex.h, GCC can't find: Section 8.2.
  8026. * RHIDE debugger GP Faults on breakpoints under Windows: Section 12.9.
  8027. * RHIDE, development environment for DJGPP: Section 22.2.
  8028. * RHIDE, includes an integrated debugger: Section 12.1.
  8029. * RSX extender: Section 3.6.
  8030. * RSXNT toolkit for developing Win32 applications: Section 3.6.
  8031. * RSXNTDJ causes linker to fail: Section 8.16.
  8032. * RSXWDK2 Windows development kit: Section 3.6.
  8033. * sbrk algorithm and QDPMI: Section 15.3.
  8034. * sbrk, Unix-like algorithm is incompatible with HW interrupts: Section 18.11.
  8035. * SCRIPT, redirecting GCC messages to a file: Section 6.10.
  8036. * Sed requires floating point: Section 22.1.
  8037. * Sed script to convert ASM to AT&T syntax: Section 17.3.
  8038. * Sed, documentation: Section 5.5.
  8039. * sizeof, result when called on a structure: Section 22.9.
  8040. * stdiostream.h, GCC can't find: Section 8.2.
  8041. * streambuf.h, GCC can't find: Section 8.2.
  8042. * STRIP makes executables smaller: Section 8.15.
  8043. * STUBEDIT, changing stack size: Section 15.9.
  8044. * STUBEDIT, effect on memory left to spawned programs: Section 15.8.
  8045. * STUBIFY fails to produce .EXE under Novell: Section 8.17.
  8046. * STUBIFY.EXE, infected by a virus: Section 6.5.
  8047. * SYMIFY, a program to read crash traceback: Section 9.2.
  8048. * TA2AS, a converter from Intel to AT&T assembly syntax: Section 17.3.
  8049. * TeX, printing the docs: Section 5.3.
  8050. * TEXI2PS, converting docs to crude PostScript: Section 5.3.
  8051. * UNIVBE, software VESA 2.0 emulation: Section 10.1.
  8052. * Warp, compatibility: Section 3.1.
  8053. * Warp, incompatibilities: Section 3.2.
  8054. * Win/NT doesn't allow "Fat DS": Section 18.6.
  8055. * Win/NT doesn't allow port I/O: Section 3.3.
  8056. * Win95 long filenames and C++ headers: Section 8.2.
  8057. * Win95, setting DJGPP environment variable: Section 8.1.
  8058. * Windows 3.x allows "Fat DS": Section 18.6.
  8059. * Windows 3.x, compatibility: Section 3.1.
  8060. * Windows 3.x, malloc/calloc fails: Section 15.5.
  8061. * Windows 95 doesn't allow more than 16MB virtual memory: Section 15.6.
  8062. * Windows 95 DPMI server loses selectors calling spawnXX: Section 3.3.
  8063. * Windows 95, shortcut files conflict with ld: Section 8.16.
  8064. * Windows 9x allows "Fat DS": Section 18.6.
  8065. * Windows 9x, compatibility: Section 3.1.
  8066. * Windows applications, writing with EMX/GCC: Section 3.6.
  8067. * Windows messes up graphics screen: Section 10.3.
  8068. * Windows, malloc/calloc failure: Section 15.4.
  8069. * Windows, memory usage for nested programs: Section 15.8.
  8070. * Windows, setting memory parameters for DJGPP: Section 3.9.
  8071. * Windows, stack size control: Section 15.9.
  8072. * windows.h header file, where to get it: Section 3.6.
  8073. * Windows/NT DPMI server loses selectors calling spawnXX: Section 3.3.
  8074. * Windows/NT, compatibility: Section 3.1.
  8075. * WinNT, setting DJGPP environment variable: Section 8.1.
  8076. * WMEMU causes undefined references when linking: Section 11.1.
  8077. * WMEMU, an alternative floating-point emulator: Section 11.1.
  8078. * WMEMU, use when debugging FP programs on non-FPU machine: Section 12.9.
  8079. * Yacc, debugging generated code: Section 12.8.
  8080.  
  8081.  
  8082.  
  8083.