PRB: Function Prototype with Undefined Structure Causes Error

ID Number: Q63058

6.00 6.00a | 6.00 6.00a

MS-DOS | OS/2

buglist6.00 fixlist6.00a

Summary:

SYMPTOMS

A function prototype, which is defined using an undeclared

structure in C version 6.0, will give the following error message:

error C2079: 'Formal' uses undefined struct/union '<union name>'

In C 5.1, the same program (assuming the structure is defined

sometime before the function itself is defined) will compile

without any errors or warnings.

RESOLUTION

For this code to compile correctly in C 6.0, the structure

definition should appear before the function prototype.

STATUS

Microsoft has confirmed this to be a problem with C version

6.0. This problem was corrected in C version 6.0a.

More Information:

The sample code below reproduces the problem.

Sample Code

-----------

/* Compile options needed: none

*/

#include "stdio.h"

// prototype

void ItFunc(struct s);

// the struct itself

struct s

{

int x;

int y;

};

void ItFunc(xstruct)

struct s xstruct;

{

printf("in the function\n");

}

Additional reference words: 6.00 6.00a