www.delorie.com/djgpp/doc/pitfalls.html | search |
terra@diku.dk
).
This document is supposed to be sort-of a checklist for DJGPP programmers especially when porting programs from either Unix or some other Dos compiler. You should be able to go through the list and say ``I thought of that'' or ``that doesn't apply to this program'' to every item. Sometimes you'll have to say ``OK, I'll document this.''
You might very well also want to take a look at the Frequently Asked Questions (FAQ).
CR LF
(or "\r\n"
if you like). Unix
files are terminated by only LF
(or "\n"
).
DJGPP will supply automatic conversion in such a way that the program
will see Unix-style files when the files are opened as text
files. This is specified using O_TEXT
for (e.g.)
open
or a t
for (e.g.) fopen
.
For binary files the corresponding names are
O_BINARY
and b
.
If unspecified, the value of _fmode
is used. This
is O_TEXT
per default.
You will want to think about the mode for every file you open. If
you're porting a Unix program, setting _fmode
to
O_BINARY
at the start of your program might be a good
idea. Read also the documentation for setmode
and
crlf2nl
.
__DJGPP__
to mark code special to DJGPP; use
__MSDOS__
to mark code special to Dos. (If you have
to write code that works with DJGPP V1 also, consider using
__GO32__
which was defined also in V1.)
/dev/
) supplied with a device
name is ignored. Anything from and including the first dot in the
final path component is also ignored. The null device is called
NUL
. See also file names.
command.com
) changes all references
to environment variables to upper case. The environment as such has
case sensitivity, but the user has no simply way of using that. Also,
there is no simple way to set a variable to the empty string.
Only one dot is allowed in every path component and it must not be the first character. Only the first eight characters before the dot and the first three after are significant. The only significance of the dot is to separate the two parts.
Since Dos uses drive letters, paths that start with a slash are not absolute.
Front slashes (/
) and backslashes (\
)
are equivalent. DJGPP's C library will make sure you see front
slashes only.
argv[0]
effect for programs, see the
FAQ on
symlinks and the
documentation for the stubedit
program if that exists.)
pipe
works
by running the producer and the consumer sequentially.
$SHELL
) note that the
standard Dos shell (command.com
) takes /c
where Unix' takes -c
. You should avoid using the shell
if you can because command.com
imposes limits on the
length of a command line and will zero the return code. Using
system
is OK.
system
function uses command.com
only for commands like
dir
and batch files, and will handle redirection for
you. See also the
FAQ
on command-lines and about
current directory.
command.com
, not Dos as such.)
/
) and not backslashes
(\
) from the library functions that give you file
names except for parts you supplied yourself. You can use
either yourself.
__dpmi_int
.
farptr.h
header file, which see.
Key words like near
, far
, and
huge
can probably be ignored or #defined away.
rename
will move files like the Unix
rename
does. In particular, the target will be deleted if it exists
and you can move directories (``prune-and-graft'').
int
is 32 bits. If you need a 16 bit
int, use short
. (For readability and portability you
might be far better off defining int8
, int16
,
and int32
types.)
unlink
(remove
) will delete files
like the Unix unlink
. This means that the read-only
flag on the file is ignored.
webmaster | delorie software privacy |
Copyright © 1998 | Updated Nov 1998 |