delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/06/08:47:47

From: myknees AT aol DOT com (Myknees)
Newsgroups: comp.os.msdos.djgpp
Subject: Borland/djgpp functions
Date: 6 Oct 1997 00:54:57 GMT
Lines: 78
Message-ID: <19971006005401.UAA21318@ladder02.news.aol.com>
NNTP-Posting-Host: ladder02.news.aol.com
Organization: AOL http://www.aol.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hello all.

I am trying to learn C++, and so was delighted to find the djgpp compiler
and the related software.  My second program (source below) was designed to
print a line, wait for input, and then print a second line and exit.

When I compile it with the slightly crippled Borland Turbo C compiler,
TCLite, it operates as expected.  

When I compile it with gcc.exe or from within RHIDE, then it doesn't run
this way.  Instead it starts off waiting for input from the console, and
then when I press a key it prints _both_ lines and exits.  i.e. It seems to
be doing the functions out of order.  Why?  

After further studying the FAQ, I tried using cprintf instead of printf,
and everything worked as expected.  Why?  

Is there a way that I can learn how about exactly what changes I'll need
to make to code as I switch between these two compilers?  I have looked in
the docs and the FAQ.


// This is based on a prog by M.L. Rinehart

#include <stdio.h>      // Necessary for printf function.
#include <conio.h>      // Necessary for getch function.

int main()  		

{

        printf( "line one before the getch  " );

        getch();        // Get char from con for a pause.

        printf("line two after the getch  ");

     	  return 0;       // Tell OS no errors.

}
                        // End


I'm not sure how helpful this information will be, but here is the environment:

TMP=C:\WINDOWS\TEMP
TEMP=C:\WINDOWS\TEMP
winbootdir=C:\WINDOWS
COMSPEC=C:\WINDOWS\COMMAND.COM
windir=C:\WINDOWS
BLASTER=A220 I7 D1
PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\ELC\DOS;C:\ELC\UTILS\DJGPP\BIN
DJGPP=C:/elc/utils/DJGPP/DJGPP.ENV
TDEL=/d-/p
D_CMD=/H/R
CMDLINE=doskey /insert
PROMPT=$p  :-)


...and here is the output of go32v2.exe:

go32/v2 version 2.0 built Aug 12 1996 22:27:23
Usage: go32 coff-image [args]
Rename this to go32.exe only if you need a go32 that can run v2 binaries as
 well as v1 binaries (old makefiles).  Put ahead of the old go32 in your PATH
 but do not delete your old go32 - leave it in the PATH after this one.
Set GO32_V2_DEBUG=y in the environment to get verbose output.

DPMI memory available: 20691 Kb
DPMI swap space available: 9161 Kb


I'm using Windows95 on a 100MHz Pentium and working in a DOS box.  Any
responses would be much appreciated.

Thanks,
--Ed (Myknees)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019