// a.h
struct a_
{
int a;
};// b.h
#include "a.h"struct b_
{
int b;
struct a_ a[9];
};
编译出错:--------------------Configuration: test - Win32 Debug--------------------
Compiling...
test.cpp
F:\MyWork\test\test.cpp(9) : error C2079: 'b' uses undefined struct 'b_'
Error executing cl.exe.test.exe - 1 error(s), 0 warning(s)

解决方案 »

  1.   

    编译环境:VC++6.0 sp5, windows xp sp2.
      

  2.   

    贴上完整的测试代码:// test.cpp : Defines the entry point for the console application.
    //#include "stdafx.h"
    struct b_ b;int main(int argc, char* argv[])
    {
    printf("Hello World!\n");
    return 0;
    }// stdafx.cpp : source file that includes just the standard includes
    // test.pch will be the pre-compiled header
    // stdafx.obj will contain the pre-compiled type information#include "stdafx.h"// TODO: reference any additional headers you need in STDAFX.H
    // and not in this file
    // a.h
    struct a_
    {
    int a;
    };// b.h
    #include "a.h"struct b_
    {
    int b;
    struct a_ a[9];
    };// stdafx.h : include file for standard system include files,
    //  or project specific include files that are used frequently, but
    //      are changed infrequently
    //#if !defined(AFX_STDAFX_H__3FE23544_1E26_4DD8_9963_6F0B380B12F8__INCLUDED_)
    #define AFX_STDAFX_H__3FE23544_1E26_4DD8_9963_6F0B380B12F8__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers#include <stdio.h>// TODO: reference additional headers your program requires here//{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_STDAFX_H__3FE23544_1E26_4DD8_9963_6F0B380B12F8__INCLUDED_)
      

  3.   

    把结构定义放到  stdafx.h  文件中
      

  4.   

    对啊,为什么把结构体定义放到CPP里,你引用的可是#include "stdafx.h"把结构体定义到stdafx.h里就没问题了
      

  5.   

    晕,都解决了啊?那就接分吧,这几天MFC板块的分真难得,结贴的人真少