help-cgicc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use Of _setmode()


From: Edward Diener
Subject: Re: Use Of _setmode()
Date: Thu, 14 Feb 2002 17:39:44 -0500
User-agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.4) Gecko/20011019 Netscape6/6.2

Alexander J. Oss wrote:

More Borland C++Builder 5 comments...

Line 48 of CgiEnvironment.cpp calls the functions _setmode() inside an
#ifdef WIN32, and that function (and its parameter _O_BINARY) doesn't exist
for Borland... I assume they are VC++ constructs.  Borland instead uses the
same stuff without the underscores.  I replaced the code with the following:

 // On Win32, use binary read to avoid CRLF conversion
#ifdef WIN32
#ifdef __BORLANDC__
 setmode(_fileno(stdin), O_BINARY);
#else
 _setmode(_fileno(stdin), _O_BINARY);
#endif
#endif

Note also that Borland's _fileno() requires <stdio.h>, which I added in the
#ifdef WIN32 which includes <io.h> and <fcntl.h> on line 34.

I have already mentioned this in a previous post but no one responded. The non-Ansi _fileno is in stdio.h in both the Microsoft Visual C++ compiler and the Borland C++ Builder compiler and therefore stdio.h needs to be included. In the Visual C++ compiler it is included by one of the other header files while in C++ Builder it is not, but this is just an implementation detail and it should be included in CgiEnvironment.cpp. I also made the same change to the source which you did regarding the _setmode call, but this can also been done by defining "_setmode" to "setmode" either in the C++ Builder IDE when building the project or from the command line. Nevertheless it should almost certainly be done in the file as you have done above to avoid end users having to know to do it from the outside.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]