KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q39343: Sizeof an Undeclared Struct Causes Violation in OS/2

Article: Q39343
Product(s): See article
Version(s): 5.10
Operating System(s): OS/2
Keyword(s): ENDUSER | | mspl13_c
Last Modified: 29-DEC-1988

The code below causes a General Protection Violation under OS/2 when
compiled with Version 5.10 of the C compiler. The code contains an
error; it attempts to determine the size of an undeclared structure
"q_block" using the sizeof() function.

This problem does not exist if the code error is corrected or if the
include file (OS2.H) is left out.

Microsoft has confirmed this to be a problem in Version 5.10. We are
researching this problem and will post new information as it becomes
available.

The following code demonstrates the problem:

#define   INCL_BASE
#include  <os2.h>

struct  q_blok  {
    char          data[80];
    };

int   add_to_queue( int num, char *pd )
{
  size = sizeof (struct q_block) ;   /* error: should read 'q_blok' */

  /* size = sizeof (struct q_blok) ;    Corrected code.             */
}

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.