⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pgqa.gml

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 GML
📖 第 1 页 / 共 5 页
字号:
.chap Commonly Asked Questions and Answers
.*
.np
.ix 'common questions'
.ix 'questions'
.ix 'answers to general problems'
As with any sophisticated piece of software, there are topics that are
not directly addressed by the descriptive portions of the manuals.
The purpose of this chapter is to anticipate common questions
concerning &cmpname..
It is difficult to predict what topics will prove to be useful but
with that in mind, we hope that this chapter will help our customers
make full use of &cmpname..
.np
A number of example programs are presented throughout.
The source text for these files can be found in the
.fi &pathnamup.\SAMPLES\GOODIES
directory.
.np
The purpose of this
.if '&target' eq 'QNX' .do begin
appendix
.do end
.el .do begin
chapter
.do end
is to present some of the more commonly asked questions from our users
and the answers to these questions.
The following topics are discussed:
.begbull $compact
.bull
How do I determine my current patch level?
.bull
How do I convert to &cmpname?
.bull
What should I know about optimization?
.if '&lang' eq 'FORTRAN 77' .do begin
.bull
How do I read a stream of binary data from a file?
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
.bull
How do I redefine math error handling with &cmpname?
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
.bull
Why can't the compiler find my include files?
.do end
.if '&lang' eq 'C' or '&lang' eq 'C/C++' .do begin
.bull
Why can't the compiler find "stdio.h"?
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
.bull
Why does the linker report a "stack segment not found" error?
.do end
.bull
How do I resolve an "Undefined Reference" linker error?
.if '&lang' eq 'FORTRAN 77' .do begin
.bull
Why aren't local variable values maintained between subprogram calls?
.do end
.if '&lang' eq 'C' or '&lang' eq 'C/C++' .do begin
.bull
Why aren't my variables set to zero?
.do end
.if '&lang' eq 'C' or '&lang' eq 'C/C++' .do begin
.bull
What does "size of DGROUP exceeds 64K" mean for 16-bit applications?
.do end
.if '&lang' eq 'C' or '&lang' eq 'C/C++' .do begin
.bull
What does "NULL assignment detected" mean in 16-bit applications?
.do end
.bull
What does "Stack Overflow!" mean?
.if '&lang' eq 'FORTRAN 77' .do begin
.bull
What are the probable causes of a General Protection Fault in 32-bit applications?
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
.bull
Which floating-point compiler option should I use for my application?
.do end
.if '&lang' eq 'C' or '&lang' eq 'C/C++' .do begin
.bull
Why do I get redefinition errors from &lnkcmdup?
.do end
.if '&target' ne 'QNX' .do begin
.bull
How can I open more than 20 files at a time?
.do end
.bull
How can I see my source files in the debugger?
.bull
What is the difference between the "d1" and "d2" compiler options?
.if '&lang' eq 'FORTRAN 77' .do begin
.bull
What is the difference between the "debug" and "d2" compiler options?
.do end
:CMT. .bull
:CMT. How do I trace back from a program crash in VIDEO?
.endbull
.*
.if '&target' ne 'QNX' .do begin
.*
.section Determining my current patch level
.*
.np
.ix 'patch level'
.ix 'patches'
.ix 'TECHINFO'
In an effort to immediately correct any problems discovered in the
originally shipped product, &company provides patches as a continued
service to its customers.  To determine the current patch level of your
&company software, a TECHINFO utility program has been provided.
This program will display your current environment variables, the patch
level of various &company software programs, and other pertinent
information, such as your
.fi AUTOEXEC.BAT
and
.fi CONFIG.SYS
files.
This information proves to be
very useful when reporting a problem to the Technical Support team.
.np
To run TECHINFO, you must ensure the &company environment variable has
been set to the directory where your &company software has been installed.
TECHINFO will pause after each screenful of information.
The output is also placed in the file
.fi TECHINFO.OUT.
.np
Below is an example of some partial output produced by running the TECHINFO
utility:
.tinyexam begin
WATCOM's Techinfo Utility, Version 1.4
Current Time: Thu Oct 27 15:58:34 1994

WATCOM                          Phone: (519) 884-0702
415 Phillip St.                 Fax: (519) 747-4971
Waterloo, Ontario
CANADA    N2L 3X2

-------------WATCOM C Environment Variables -------------
WATCOM=<c:\watcom>
EDPATH=<c:\watcom\eddat>
INCLUDE=<c:\watcom\h;c:\watcom\h\os2>
FINCLUDE=<c:\watcom\src\fortran;c:\watcom\src\fortran\win>
LIBOS2=<c:\watcom\lib286\os2;c:\watcom\lib286>
PATH=<c:\dos;c:\windows;c:\watcom\binw>
TMP=<h:\temp>
File 'c:\watcom\binw\wcc386.exe' has been patched to level '.d'
.li ...etc...
.tinyexam end
.np
In this example, the software has been patched to level "d".
In most cases, all tools will share a common patch level.
However, there are instances where certain tools have been patched
to one level while others are patched to a different level.
For example, the compiler may be patched to level "d" while the
debugger is only patched to level "c".
Basically, this means that there were no debugger changes in
the D-level patches.
.np
If you run the TECHINFO utility, and determine that you are not at the
current patch level, it is recommended that you update your software.
.ix 'BBS'
.ix 'bulletin board'
.ix 'FTP site'
.ix 'CompuServe'
Patches are available on &company's bulletin board, &company's FTP
site and CompuServe.
They are available 24 hours a day.
Patches are also available on the current release CD-ROM.
Each patch will include a batch file that allows you to apply the
patches to your existing software.
Note that patches must be applied in sequential order, as each patch
depends on the previous one.
.do end
.*
.section Converting to &cmpname
.*
.np
.ix 'converting to &cmpname'
.ix 'converting to &cmpname' 'common problems'
.ix 'converting to &cmpname' 'what you need to know'
.ix '&cmpname' 'converting to'
.if '&lang' eq 'FORTRAN 77' .do begin
.ix 'FORTRAN 77' 'Extensions'
.ix 'SAVE'
Applications written in ANSI standard FORTRAN 77 code usually only need
to be recompiled with the &cmpname compiler.
In addition to the ANSI standard, many compilers support specific
extensions.
If you are porting code from a UNIX platform or other DOS compilers,
check
.us Appendix A - Extensions to Standard FORTRAN 77
of the
.book &company &lang Language Reference,
to determine which FORTRAN 77 extensions are supported.
.np
By default, most &lang compilers preserve the values of local
variables in a subprogram between calls.
With &cmpname, local variables are kept on the stack and their values
are popped from the stack when exiting a subprogram.
To preserve local variables, use the &lang SAVE statement for
variables that you wish to preserve, or the "save" compiler option to
preserve all local variables.
Note that the use of the "save" compiler option causes an overall
performance degradation.
.np
&cmpname uses register-based parameter passing as a default, however,
the compiler is flexible enough to use different calling conventions
on a per function basis.
Auxiliary pragmas can be used to specify the calling convention that
is to be used to interface with assembler code.
This enables you to explicitly state how parameters are to be passed
to the assembler code.
This topic is described in the "Pragmas" chapter
.if '&target' ne 'QNX' .do begin
of the
.book &cmpname User's Guide
.do end
under "Describing Argument Information".
See also the chapter entitled :HDREF refid='cmixf'..
:cmt. .np
:cmt. For example, the statement "C$PRAGMA AUX foo PARM ROUTINE []" can be used
:cmt. to indicate that the parameters for a procedure named "foo" will be managed
:cmt. by the called procedure, "foo" and none of the registers will be used.
:cmt. If the application interfaces with assembler code that assumes parameters
:cmt. are passed on the stack, then you must either convert the assembler code
:cmt. or use "C$PRAGMA" statements to define the calling convention for the
:cmt. assembler routines.
.do end
.*
.if '&lang' eq 'C' or '&lang' eq 'C/C++' .do begin
There are some common steps involved in converting C programs written
for other compilers.
Conversion from UNIX and other IBM-compatible PC compilers will be
covered in detail later.
There are six major problems with most programs that are ported to
&cmpname..
The assumptions that most foreign programs make that may be invalid
when using &cmpname are:
.autonote
.note
sizeof( pointer ) == sizeof( int )
.np
(true for 16-bit systems except "far" pointers,
true for 32-bit systems except "far" pointers)
.note
sizeof( long ) == sizeof( int )
.np
(not true for 16-bit systems)
.note
sizeof( short ) == sizeof( int )
.np
(not true for 32-bit systems)
.note
arguments are always passed on the stack
.note
dereferencing the
.id NULL
pointer
.note
"char" is either signed or unsigned
.endnote
.np
These assumptions are very easy to make when developing programs for
only one system.
The first point becomes important when you move a program to 80x86
systems.
.ix 'integer/pointer equivalence'
.ix 'invalid conversion'
.ix 'memory models' 'what you need to know'
Depending on the memory model, the size of an integer might not equal
the size of a pointer.
You might ask how this assumption is made in programs.
The C language will assume that a function returns an integer unless
told otherwise.
If a programmer does not declare a function as returning a pointer,
the compiler will generate code which would convert an integer to a
pointer.
On other systems, where the size of an integer is equal to the size of
a pointer this would amount to nothing because no conversion was
necessary (to change size).
The older C compilers did not worry about warning the programmer about
this condition and as such this error is imbedded in a lot of older C
code.
As C was moved to other machines, it became apparent that this
assumption was no longer valid for all machines.
The 80x86 architecture can have 16-bit integers and 32-bit pointers
(in the compact, large, and huge memory models), which means that
more care must be taken when working with declarations (converting
an int to a 32-bit pointer will result in a segment value of 0x0000
or 0xffff).
Similarly, the 386 architecture can have 32-bit integers and 48-bit
pointers.
.np
The &cmpname compiler will complain about incorrect pointer and
integer mixing thus making programs compiled with &cmpname much more
portable.
For instance, if the &cmpname compiler complains about your usage of
the "malloc" memory allocation function then you probably forgot to
include "<stdlib.h>" which contains the prototype of the "malloc"
function.
.exam begin
extern void *malloc( unsigned );
.exam end
.pc
The &cmpname compiler was complaining about you trying to assign an
integer (the value returned by "malloc") to a pointer.
By including the header file with the correct prototype, the &cmpname
compiler can validate that you are in fact assigning a pointer value
to a pointer.
.np
.ix 'arguments' 'what you need to know'
.ix 'pushing arguments' 'what you need to know'
.ix 'parameters' 'what you need to know'
.ix 'calling convention' 'what you need to know'
.ix '&cmpname' 'calling convention'
.ix '&cmpname' 'unique aspects'
.ix 'ISO/ANSI standard' 'variable number of arguments'
Passing arguments on the stack has been the method used by most older
compilers because it allowed the C library function "printf" to work
with a variable number of arguments.
Older C compilers catered to a few functions by forcing all the
argument handling to be handled by the caller of the function.
With the advent of the ANSI (and later ISO) standard, which forced all
functions expecting a variable number of arguments to be declared properly,
compilers can generate smaller code for routines that did not require
a variable number of arguments.
.exam begin
/* function accepting two arguments */
extern FILE *fopen( char *, char * );
/* function accepting a variable number of arguments */
extern int printf( char *, ... );
.exam end
.pc
The &cmpname compiler takes advantage of this part of the ISO/ANSI
standard by passing arguments in registers (for the first few
arguments).
.ix 'registers' 'calling convention'
If there are not enough registers for all of the arguments, the rest
of the arguments are passed on the stack but the routine being called
is responsible for removing them from the stack.
By default,
the &cmpname compiler uses this calling convention because it results
in faster procedure calls and smaller code.
The &cmpname calling convention carries with it a responsibility to
ensure that all functions are prototyped correctly before they are
used.
For instance, if a procedure is called with too few arguments, the
assumptions that the code generator made (while generating the code)
will be invalidated.
The code generator assumes that AX (EAX for the 32-bit compiler)
and any other registers used to pass arguments will be modified by the
called function.
The code generator also assumes that the exact amount of arguments
pushed on the stack will be removed by the function that is called.
It is important to recognize this aspect of the &cmpname compiler
because the program will simply not work unless the caller and the
function being called strictly agree on the number and types of the
arguments being passed.
See the "Assembly Language Considerations" chapter
.if '&target' ne 'QNX' .do begin
in the

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -