QCW9201008: Functions in BIOS.H, DOS.H Prototyped Incorrectly

ID Number: Q81298

1.00

WINDOWS

buglist1.00

Summary:

PROBLEM ID: QCW9201008

SYMPTOMS

In Microsoft QuickC for Windows (QC/Win) version 1.0, using

_bios_disk(), _dos_findfirst(), _dos_findnext(), _dos_gedate(),

_dos_gettime(), _dos_setdate(), and _dos_settime() will generate

warnings when passed parameters declared using the non-ANSI

structure names. All of the online help examples for these

functions demonstrate this problem.

CAUSE

ANSI requires that all implementation defined extensions to the C

language be prepended with an underscore, or have the first letter

of the extension capitalized. In previous versions of the Microsoft

C compiler, not all extensions were required to have a leading

underscore. To maintain compatibility with existing code, when

MS-extensions are enabled (/Ze), structures for both ANSI and

non-ANSI compatibility are declared.

The support mechanism for MS-extensions is implemented by declaring

two identical structures with different names (one with an

underscore prepended, and one with no leading underscore). In the

header file <dos.h>, for example, the structures _dostime_t and

dostime_t are declared as follows:

struct _dostime_t {

unsigned char hour; /* 0-23 */

unsigned char minute; /* 0-59 */

unsigned char second; /* 0-59 */

unsigned char hsecond; /* 0-99 */

};

#ifndef __STDC__

/* Non-ANSI names for compatibility */

struct dostime_t {

unsigned char hour; /* 0-23 */

unsigned char minute; /* 0-59 */

unsigned char second; /* 0-59 */

unsigned char hsecond; /* 0-99 */

};

#endif

These types of duplicate declarations allow the user to use either

the ANSI name (that is, _dostime_t) or the MS-extension (that is,

dostime_t). When compiling with MS-extensions selected, however,

using the MS-extension (with no leading underscore) will generate

warnings because the functions are prototyped with the ANSI names.

RESOLUTION

While the best solution is to use the ANSI names, the header files

can be modified to correct this problem. In place of the non-ANSI

structure declaration, a #define preprocessor statement may be put

in the include file. The #define statement will replace the

non-ANSI name with the ANSI name. For example the dostime_t

declarations will resemble the following:

struct _dostime_t {

unsigned char hour; /* 0-23 */

unsigned char minute; /* 0-59 */

unsigned char second; /* 0-59 */

unsigned char hsecond; /* 0-99 */

};

#ifndef __STDC__

/* Non-ANSI names for compatibility */

#define dostime_t _dostime_t

#endif

STATUS

Microsoft has confirmed this to be a problem in Microsoft QuickC

for Windows version 1.0. This problem has been corrected in C/C++

version 7.0. We are researching this problem and will post new

information here as it becomes available.

More Information:

When the sample code below is compiled, the following errors will be

generated:

warning C4049 : 'argument' : indirection to different types

warning C4024 : '_dos_gettime' : different types : parameter 1

Sample Code

-----------

/* Compile options needed: /Ze

*/

#include <stdio.h>

#include <dos.h>

void main()

{

struct dostime_t time;

/* Get current time values */

_dos_gettime( &time );

printf( "The time is %02d:%02d\n", time.hour, time.minute );

}

Additional reference words: 1.00 qcw qcwin