Mail Archives: djgpp/1997/12/30/03:02:54
pneyz wrote:
>
> I have DJGPP installed correctly and everything, but a lot of my
> programs will only work in Win95, and not in pure DOS. These programs
> all make use of command line parameters, and that is where the problem
> is manifesting. I managed to narrow it down to the following:
>
> int main (int argc, char *argv[])
> {
> if (!strcmp(argv[1], "-h")) return 1;
> else return 0;
> }
>
> That should test to see if argv[1] is "-h" and if it is, return 1, and
> if not, return 0. This works fine in Win95, but in DOS I get a error
> screen about SIGSENT (actually, I'm not too sure about what it says, as
> I can't reproduce it in Win95 right now). Any code before that executes
> fine, but it stops there. Any help will be much appreciated.
Better start switching to a slightly more defensive programming style.
If you call your program without arguments, argv[1] is a NULL pointer,
and there is only very little point in checking if INT 0 points
to memory location "-h".
The problem is that W95 is a really f*d up DPMI hosts that doesn't
catch those errors. Try
char foo[256];
char *bar=NULL;
strcpy(bar,"Hello");
strcpy(foo,bar);
puts(foo);
under W95 & CWSDPMI and go figure.
--
Ciao
Tom
*************************************************************
* Thomas Demmer *
* Lehrstuhl fuer Stroemungsmechanik *
* Ruhr-Uni-Bochum *
* Universitaetsstr. 150 *
* D-44780 Bochum *
* Tel: +49 234 700 6434 *
* Fax: +49 234 709 4162 *
* http://www.lstm.ruhr-uni-bochum.de/~demmer *
*************************************************************
- Raw text -