KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q41654: QuickC 2.00 README.DOC: /Ze, /Za (Enable/Disable Extensions)

Article: Q41654
Product(s): See article
Version(s): 2.00
Operating System(s): MS-DOS
Keyword(s): ENDUSER | | mspl13_c
Last Modified: 28-FEB-1989

The following information is taken from the QuickC Version 2.00
README.DOC file, part 3, "Notes on 'QuickC Tool Kit.'" The following
notes refer to specific pages in "QuickC Tool Kit."

Page 101  /Ze, /Za (Enable or Disable Language Extensions)

Add the following notes to the explanation of /Ze and /Za:

In extremely rare cases, you may want to cast a function pointer to a
data pointer. QuickC uses the code segment (cs:), while Microsoft C
5.1 uses the data segment (ds:). The program below attempts to cast a
function pointer (pfunc) to a pointer to an int (pdata):

    main()
    {
      int (*pfunc)();
      int *pdata;

      pdata = (int *) pfunc;
     }

The ANSI standard does not permit such casts. When you use /Za to
enforce ANSI compatibility, this program triggers error C2068. When
you use /Ze and /W3, this program generates a warning C4074.

To maintain ANSI and C 5.1 portability, cast the function pointer to
an int before casting it to a data pointer. The following line is
perfectly acceptable. It generates to errors or warnings.

   pdata = (int *) (int) pfunc;

A second method is to declare pfunc as a union that can act as a
function pointer or a data pointer.

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.